Copied!

Represents a set of space-separated attributes of an element attribute.

  • property-read int $length The number of tokens.
  • property-read string $value A space-separated list of the tokens.
AbstractInterface
Methods
public abstract add(string $tokens)
 

Adds the given tokens to the list.

  • param string $tokens
  • return \DOMAttr|false|null
public abstract contains(string $token) : bool
 

Returns true if the list contains the given token, otherwise false.

  • param string $token the token you want to check for the existence of in the list
  • return bool true if the list contains the given token, otherwise false
public abstract entries() : ArrayIterator
 

Returns an iterator allowing you to go through all tokens contained in the list.

  • return \ArrayIterator
public abstract item(int $index)
 

Returns an item in the list by its index (returns null if the number is greater than or equal to the length of the list).

  • param int $index the zero-based index of the item you want to return
  • return string|null
public abstract remove(string $tokens)
 

Removes the specified tokens from the list. If the string does not exist in the list, no error is thrown.

  • param string $tokens
  • return \DOMAttr|false|null
public abstract replace(string $old, string $new)
 

Replaces an existing token with a new token.

  • param string $old the token you want to replace
  • param string $new the token you want to replace $old with
  • return \DOMAttr|false|null
public abstract toggle(string $token, ?bool $force = NULL) : bool
 

Removes a given token from the list and returns false. If token doesn't exist it's added and the function returns true.

  • param string $token the token you want to toggle
  • param bool $force A Boolean that, if included, turns the toggle into a one way-only operation. If set to false, the token will only be removed but not added again. If set to true, the token will only be added but not removed again.
  • return bool false if the token is not in the list after the call, or true if the token is in the list after the call
© 2025 Bruce Wells