From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- vendor/sabre/dav/lib/DAV/SimpleCollection.php | 72 ++++++++++++++------------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'vendor/sabre/dav/lib/DAV/SimpleCollection.php') 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 @@ 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); - } - - } -- cgit v1.2.3