3 namespace RemexHtml\Tokenizer;
6 * An Attributes implementation which is a simple array proxy.
8 class PlainAttributes implements Attributes {
10 protected $attrObjects;
12 public function __construct( $data = [] ) {
16 public function merge( Attributes $other ) {
17 foreach ( $other as $name => $value ) {
18 if ( !isset( $this[$name] ) ) {
19 $this[$name] = $value;
24 public function offsetExists( $key ) {
25 return isset( $this->data[$key] );
28 public function offsetGet( $key ) {
29 return $this->data[$key];
32 public function offsetSet( $key, $value ) {
33 $this->data[$key] = $value;
36 public function offsetUnset( $key ) {
37 unset( $this->data[$key] );
40 public function getIterator() {
41 return new ArrayIterator( $this->data );
44 public function getValues() {
48 public function getObjects() {
49 if ( $this->attrObjects === null ) {
51 foreach ( $this->data as $name => $value ) {
52 $result[$name] = new Attribute( $name, null, null, $name, $value );
54 $this->attrObjects = $result;
56 return $this->attrObjects;
59 public function count() {
60 return count( $this->data );