diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php index fded5e474..e0bdecc09 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mock; use Sabre\DAV; @@ -19,22 +21,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAV\Collection { - +class Collection extends DAV\Collection +{ protected $name; protected $children; protected $parent; /** - * Creates the object + * Creates the object. * - * @param string $name - * @param array $children + * @param string $name + * @param array $children * @param Collection $parent - * @return void */ - function __construct($name, array $children = [], Collection $parent = null) { - + public function __construct($name, array $children = [], Collection $parent = null) + { $this->name = $name; foreach ($children as $key => $value) { if (is_string($value)) { @@ -48,7 +49,6 @@ class Collection extends DAV\Collection { } } $this->parent = $parent; - } /** @@ -58,14 +58,13 @@ class Collection extends DAV\Collection { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -84,41 +83,39 @@ class Collection extends DAV\Collection { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = '') + { if (is_resource($data)) { $data = stream_get_contents($data); } $this->children[] = new File($name, $data, $this); - return '"' . md5($data) . '"'; + return '"'.md5($data).'"'; } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { $this->children[] = new self($name); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { return $this->children; - } /** @@ -126,43 +123,35 @@ class Collection extends DAV\Collection { * * @param \Sabre\DAV\INode $node */ - function addNode(\Sabre\DAV\INode $node) { - + public function addNode(\Sabre\DAV\INode $node) + { $this->children[] = $node; - } /** * Removes a childnode from this node. * * @param string $name - * @return void */ - function deleteChild($name) { - + public function deleteChild($name) + { foreach ($this->children as $key => $value) { - if ($value->getName() == $name) { unset($this->children[$key]); + return; } - } - } /** * Deletes this collection and all its children,. - * - * @return void */ - function delete() { - + public function delete() + { foreach ($this->getChildren() as $child) { $this->deleteChild($child->getName()); } $this->parent->deleteChild($this->getName()); - } - } |