1 | <?php declare(strict_types=1); |
||
17 | trait ElementsAwareTrait |
||
18 | { |
||
19 | /** |
||
20 | * @var \ArrayIterator |
||
21 | */ |
||
22 | protected $elements; |
||
23 | |||
24 | /** |
||
25 | * initialize the elements property before use |
||
26 | */ |
||
27 | 129 | protected function initElements() : void |
|
31 | |||
32 | /** |
||
33 | * @return ElementInterface |
||
34 | */ |
||
35 | 26 | public function newElement() : ElementInterface |
|
39 | |||
40 | /** |
||
41 | * @param string $name element name |
||
42 | * @return ElementIterator |
||
43 | */ |
||
44 | 17 | public function getElementIterator(string $name) : ElementIterator |
|
48 | |||
49 | /** |
||
50 | * @param string $name element name |
||
51 | * @return boolean true if the element exists |
||
52 | */ |
||
53 | 4 | public function hasElement(string $name) : bool |
|
59 | |||
60 | /** |
||
61 | * @param ElementInterface $element |
||
62 | * @return $this |
||
63 | */ |
||
64 | 30 | public function addElement(ElementInterface $element) |
|
70 | |||
71 | /** |
||
72 | * Returns all the item's optional elements |
||
73 | * @return iterable |
||
74 | */ |
||
75 | 17 | public function getAllElements() : iterable |
|
79 | |||
80 | /** |
||
81 | * Returns the item's optional elements tag names |
||
82 | * @return iterable |
||
83 | */ |
||
84 | 10 | public function listElements() : iterable |
|
90 | |||
91 | /** |
||
92 | * @return \Generator |
||
93 | */ |
||
94 | 6 | public function getElementsGenerator() : \Generator |
|
102 | } |
||
103 |