Skip to content
Snippets Groups Projects

Added tests and countable interface

2 unresolved threads
Files
2
+ 11
1
@@ -67,7 +67,7 @@
* @see \Drupal\Component\Render\PlainTextOutput::renderFromHtml()
* @see \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols()
*/
class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface {
class Attribute implements \ArrayAccess, \IteratorAggregate, \Countable, MarkupInterface {
/**
* Stores the attribute data.
@@ -382,6 +382,16 @@ public function jsonSerialize(): string {
return (string) $this;
}
/**
* Returns the number of attributes stored in the Attribute object.
*
* @return int
* The number of attributes.
*/
public function count(): int {
return count($this->storage);
}
/**
* Merges an Attribute object into the current storage.
*
Loading