| Total Complexity | 11 |
| Total Lines | 85 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class ParentNode |
||
| 16 | { |
||
| 17 | /** @var ContainerInterface */ |
||
| 18 | private $container; |
||
| 19 | /** @var ParentNode[] */ |
||
| 20 | private $children = []; |
||
| 21 | /** @var ParentNode */ |
||
| 22 | private $parent; |
||
| 23 | /** @var ItemInterface */ |
||
| 24 | private $parentItem; |
||
| 25 | |||
| 26 | public function __construct(ContainerInterface $item) |
||
| 27 | { |
||
| 28 | $this->container = $item; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function getContainer(): ContainerInterface |
||
| 32 | { |
||
| 33 | return $this->container; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function addChild(ParentNode $item): void |
||
| 37 | { |
||
| 38 | $this->children[get_class($item->getContainer())] = $item; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function hasChildren(): bool |
||
| 42 | { |
||
| 43 | return false === empty($this->children); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return ParentNode[] |
||
| 48 | */ |
||
| 49 | public function getChildren(): array |
||
| 52 | } |
||
| 53 | |||
| 54 | public function has(string $name): bool |
||
| 55 | { |
||
| 56 | return array_key_exists($name, $this->children); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function get(string $name): ParentNode |
||
| 60 | { |
||
| 61 | return $this->children[$name]; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return ParentNode |
||
| 66 | */ |
||
| 67 | public function getParent(): ?ParentNode |
||
| 68 | { |
||
| 69 | return $this->parent; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param ParentNode $parent |
||
| 74 | * @return ParentNode |
||
| 75 | */ |
||
| 76 | public function setParent(ParentNode $parent): ParentNode |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @return ItemInterface |
||
| 85 | */ |
||
| 86 | public function getParentItem(): ?ItemInterface |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @param ItemInterface $parentItem |
||
| 93 | * @return ParentNode |
||
| 94 | */ |
||
| 95 | public function setParentItem(ItemInterface $parentItem): ParentNode |
||
| 100 | } |
||
| 101 | } |
||
| 102 |