aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/Mock
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Mock')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php73
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php84
2 files changed, 67 insertions, 90 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());
-
}
-
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php
index a624b6b6b..d48ddaa92 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php
@@ -1,11 +1,13 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\Mock;
use Sabre\DAV;
/**
- * Mock File
+ * Mock File.
*
* See the Collection in this directory for more details.
*
@@ -13,34 +15,32 @@ use Sabre\DAV;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class File extends DAV\File {
-
+class File extends DAV\File
+{
protected $name;
protected $contents;
protected $parent;
protected $lastModified;
/**
- * Creates the object
+ * Creates the object.
*
- * @param string $name
- * @param resource $contents
+ * @param string $name
+ * @param resource $contents
* @param Collection $parent
- * @param int $lastModified
- * @return void
+ * @param int $lastModified
*/
- function __construct($name, $contents, Collection $parent = null, $lastModified = -1) {
-
+ public function __construct($name, $contents, Collection $parent = null, $lastModified = -1)
+ {
$this->name = $name;
$this->put($contents);
$this->parent = $parent;
- if ($lastModified === -1) {
+ if (-1 === $lastModified) {
$lastModified = time();
}
$this->lastModified = $lastModified;
-
}
/**
@@ -50,26 +50,23 @@ class File extends DAV\File {
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
return $this->name;
-
}
/**
* Changes the name of the node.
*
* @param string $name
- * @return void
*/
- function setName($name) {
-
+ public function setName($name)
+ {
$this->name = $name;
-
}
/**
- * Updates the data
+ * Updates the data.
*
* The data argument is a readable stream resource.
*
@@ -86,66 +83,59 @@ class File extends DAV\File {
* return an ETag, and just return null.
*
* @param resource $data
+ *
* @return string|null
*/
- function put($data) {
-
+ public function put($data)
+ {
if (is_resource($data)) {
$data = stream_get_contents($data);
}
$this->contents = $data;
- return '"' . md5($data) . '"';
+ return '"'.md5($data).'"';
}
/**
- * Returns the data
+ * Returns the data.
*
* This method may either return a string or a readable stream resource
*
* @return mixed
*/
- function get() {
-
+ public function get()
+ {
return $this->contents;
-
}
/**
- * Returns the ETag for a file
+ * Returns the ETag for a file.
*
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
*
* Return null if the ETag can not effectively be determined
- *
- * @return void
*/
- function getETag() {
-
- return '"' . md5($this->contents) . '"';
-
+ public function getETag()
+ {
+ return '"'.md5($this->contents).'"';
}
/**
- * Returns the size of the node, in bytes
+ * Returns the size of the node, in bytes.
*
* @return int
*/
- function getSize() {
-
+ public function getSize()
+ {
return strlen($this->contents);
-
}
/**
- * Delete the node
- *
- * @return void
+ * Delete the node.
*/
- function delete() {
-
+ public function delete()
+ {
$this->parent->deleteChild($this->name);
-
}
/**
@@ -154,10 +144,8 @@ class File extends DAV\File {
*
* @return int
*/
- function getLastModified() {
-
+ public function getLastModified()
+ {
return $this->lastModified;
-
}
-
}