ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SimpleCollection.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV;
4
16
22 protected $children = [];
23
29 protected $name;
30
40 function __construct($name, array $children = []) {
41
42 $this->name = $name;
43 foreach ($children as $child) {
44
45 if (!($child instanceof INode)) throw new Exception('Only instances of Sabre\DAV\INode are allowed to be passed in the children argument');
46 $this->addChild($child);
47
48 }
49
50 }
51
58 function addChild(INode $child) {
59
60 $this->children[$child->getName()] = $child;
61
62 }
63
69 function getName() {
70
71 return $this->name;
72
73 }
74
88 function getChild($name) {
89
90 if (isset($this->children[$name])) return $this->children[$name];
91 throw new Exception\NotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\'');
92
93 }
94
100 function getChildren() {
101
102 return array_values($this->children);
103
104 }
105
106
107}
An exception for terminatinating execution or to throw for unit testing.
Collection class.
Definition: Collection.php:15
Main Exception class.
Definition: Exception.php:18
addChild(INode $child)
Adds a new childnode to this collection.
getChildren()
Returns a list of children for this collection.
getName()
Returns the name of the collection.
getChild($name)
Returns a child object, by its name.
__construct($name, array $children=[])
Creates this node.
The INode interface is the base interface, and the parent class of both ICollection and IFile.
Definition: INode.php:12
getName()
Returns the name of the node.