ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
AbstractParentItem.php
Go to the documentation of this file.
2
7abstract class AbstractParentItem extends AbstractBaseItem implements isParent
8{
9
13 protected $children = [];
14
18 public function getChildren() : array
19 {
20 return $this->children;
21 }
22
26 public function withChildren(array $children) : isParent
27 {
28 $clone = clone($this);
29 $clone->children = $children;
30
31 return $clone;
32 }
33
37 public function appendChild(isChild $child) : isParent
38 {
39 $this->children[] = $child;
40
41 return $this;
42 }
43
47 public function hasChildren() : bool
48 {
49 return (count($this->children) > 0);
50 }
51
55 public function removeChild(isChild $child_to_remove) : isParent
56 {
57 $this->children = array_filter($this->children, static function (isItem $item) use ($child_to_remove) : bool {
58 return $item !== $child_to_remove;
59 });
60
61 return $this;
62 }
63}
An exception for terminatinating execution or to throw for unit testing.