| Total Complexity | 5 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | trait TParent |
||
| 18 | { |
||
| 19 | protected ?IHtmlElement $parent = null; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Set parent element |
||
| 23 | * @param IHtmlElement|null $parent |
||
| 24 | */ |
||
| 25 | 3 | public function setParent(?IHtmlElement $parent = null): void |
|
| 26 | { |
||
| 27 | 3 | $this->parent = $parent; |
|
| 28 | 3 | $this->afterParentSet(); |
|
| 29 | 3 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * Returns parent element |
||
| 33 | * @return IHtmlElement|null |
||
| 34 | */ |
||
| 35 | 1 | public function getParent(): ?IHtmlElement |
|
| 36 | { |
||
| 37 | 1 | return $this->parent; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Change element settings after new parent has been set |
||
| 42 | */ |
||
| 43 | 3 | protected function afterParentSet(): void |
|
| 45 | 3 | } |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Add $element after current one - if there is any parent |
||
| 49 | * @param IHtmlElement|string $element |
||
| 50 | * @param string $alias |
||
| 51 | */ |
||
| 52 | 1 | public function append($element, ?string $alias = null): void |
|
| 56 | } |
||
| 57 | 1 | } |
|
| 59 |