aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/SimpleCollection.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-12-04 10:25:11 +0000
committerMario <mario@mariovavti.com>2019-12-04 10:25:11 +0000
commitbde429cff649237984903a252ba1a718e6d74f53 (patch)
treeb2b2570159cfb37689e6ce3b96c3b1b988d676cc /vendor/sabre/dav/lib/DAV/SimpleCollection.php
parentcc9f41df5f83bcab435d6fb941b5a8f5b1457037 (diff)
parent4c8d33d1eb2a804aa70a7bc677d6c73d0d94816b (diff)
downloadvolse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.gz
volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.bz2
volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.zip
Merge branch '4.6RC'4.6
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/SimpleCollection.php')
-rw-r--r--vendor/sabre/dav/lib/DAV/SimpleCollection.php72
1 files changed, 38 insertions, 34 deletions
diff --git a/vendor/sabre/dav/lib/DAV/SimpleCollection.php b/vendor/sabre/dav/lib/DAV/SimpleCollection.php
index 998cfcbff..1fbb6982d 100644
--- a/vendor/sabre/dav/lib/DAV/SimpleCollection.php
+++ b/vendor/sabre/dav/lib/DAV/SimpleCollection.php
@@ -1,9 +1,13 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV;
+use InvalidArgumentException;
+
/**
- * SimpleCollection
+ * SimpleCollection.
*
* The SimpleCollection is used to quickly setup static directory structures.
* Just create the object with a proper name, and add children to use it.
@@ -12,64 +16,64 @@ namespace Sabre\DAV;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class SimpleCollection extends Collection {
-
+class SimpleCollection extends Collection
+{
/**
- * List of childnodes
+ * List of childnodes.
*
* @var INode[]
*/
protected $children = [];
/**
- * Name of this resource
+ * Name of this resource.
*
* @var string
*/
protected $name;
/**
- * Creates this node
+ * Creates this node.
*
* The name of the node must be passed, child nodes can also be passed.
* This nodes must be instances of INode
*
- * @param string $name
+ * @param string $name
* @param INode[] $children
*/
- function __construct($name, array $children = []) {
-
+ public function __construct($name, array $children = [])
+ {
$this->name = $name;
- foreach ($children as $child) {
-
- if (!($child instanceof INode)) throw new Exception('Only instances of Sabre\DAV\INode are allowed to be passed in the children argument');
+ foreach ($children as $key => $child) {
+ if (is_string($child)) {
+ $child = new SimpleFile($key, $child);
+ } elseif (is_array($child)) {
+ $child = new self($key, $child);
+ } elseif (!$child instanceof INode) {
+ throw new InvalidArgumentException('Children must be specified as strings, arrays or instances of Sabre\DAV\INode');
+ }
$this->addChild($child);
-
}
-
}
/**
- * Adds a new childnode to this collection
+ * Adds a new childnode to this collection.
*
* @param INode $child
- * @return void
*/
- function addChild(INode $child) {
-
+ public function addChild(INode $child)
+ {
$this->children[$child->getName()] = $child;
-
}
/**
- * Returns the name of the collection
+ * Returns the name of the collection.
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
return $this->name;
-
}
/**
@@ -82,26 +86,26 @@ class SimpleCollection extends Collection {
* exist.
*
* @param string $name
+ *
* @throws Exception\NotFound
+ *
* @return INode
*/
- function getChild($name) {
-
- if (isset($this->children[$name])) return $this->children[$name];
- throw new Exception\NotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\'');
-
+ public function getChild($name)
+ {
+ if (isset($this->children[$name])) {
+ return $this->children[$name];
+ }
+ throw new Exception\NotFound('File not found: '.$name.' in \''.$this->getName().'\'');
}
/**
- * Returns a list of children for this collection
+ * Returns a list of children for this collection.
*
* @return INode[]
*/
- function getChildren() {
-
+ public function getChildren()
+ {
return array_values($this->children);
-
}
-
-
}