diff options
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Xml/Property')
11 files changed, 207 insertions, 229 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php index 258806e4a..990302054 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Complex.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Element\XmlFragment; @@ -15,8 +17,8 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Complex extends XmlFragment { - +class Complex extends XmlFragment +{ /** * The deserialize method is called during xml parsing. * @@ -36,15 +38,17 @@ class Complex extends XmlFragment { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $xml = $reader->readInnerXml(); - if ($reader->nodeType === Reader::ELEMENT && $reader->isEmptyElement) { + if (Reader::ELEMENT === $reader->nodeType && $reader->isEmptyElement) { // Easy! $reader->next(); + return null; } // Now we have a copy of the inner xml, we need to traverse it to get @@ -56,21 +60,19 @@ class Complex extends XmlFragment { $text = ''; while (true) { - switch ($reader->nodeType) { - case Reader::ELEMENT : + case Reader::ELEMENT: $nonText = true; $reader->next(); continue 2; - case Reader::TEXT : - case Reader::CDATA : + case Reader::TEXT: + case Reader::CDATA: $text .= $reader->value; break; - case Reader::END_ELEMENT : + case Reader::END_ELEMENT: break 2; } $reader->read(); - } // Make sure we advance the cursor one step further. @@ -78,12 +80,10 @@ class Complex extends XmlFragment { if ($nonText) { $new = new self($xml); + return $new; } else { return $text; } - } - - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php index 101a0f0c9..05a00c5e5 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use DateTime; @@ -19,42 +21,40 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class GetLastModified implements Element { - +class GetLastModified implements Element +{ /** - * time + * time. * * @var DateTime */ public $time; /** - * Constructor + * Constructor. * * @param int|DateTime $time */ - function __construct($time) { - + public function __construct($time) + { if ($time instanceof DateTime) { $this->time = clone $time; } else { - $this->time = new DateTime('@' . $time); + $this->time = new DateTime('@'.$time); } // Setting timezone to UTC $this->time->setTimezone(new DateTimeZone('UTC')); - } /** - * getTime + * getTime. * * @return DateTime */ - function getTime() { - + public function getTime() + { return $this->time; - } /** @@ -70,14 +70,12 @@ class GetLastModified implements Element { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->write( - HTTP\Util::toHTTPDate($this->time) + HTTP\toDate($this->time) ); - } /** @@ -99,12 +97,12 @@ class GetLastModified implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(new DateTime($reader->parseInnerTree())); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php index 6c4f11b87..c479c1602 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -10,7 +12,7 @@ use Sabre\Xml\Reader; use Sabre\Xml\Writer; /** - * Href property + * Href property. * * This class represents any WebDAV property that contains a {DAV:}href * element, and there are many. @@ -23,17 +25,17 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class Href implements Element, HtmlOutput { - +class Href implements Element, HtmlOutput +{ /** - * List of uris + * List of uris. * * @var array */ protected $hrefs; /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -42,35 +44,32 @@ class Href implements Element, HtmlOutput { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { if (is_string($hrefs)) { $hrefs = [$hrefs]; } $this->hrefs = $hrefs; - } /** * Returns the first Href. * - * @return string + * @return string|null */ - function getHref() { - - return $this->hrefs[0]; - + public function getHref() + { + return $this->hrefs[0] ?? null; } /** - * Returns the hrefs as an array + * Returns the hrefs as an array. * * @return array */ - function getHrefs() { - + public function getHrefs() + { return $this->hrefs; - } /** @@ -90,15 +89,13 @@ class Href implements Element, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getHrefs() as $href) { $href = Uri\resolve($writer->contextUri, $href); $writer->writeElement('{DAV:}href', $href); } - } /** @@ -113,16 +110,17 @@ class Href implements Element, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { $links = []; foreach ($this->getHrefs() as $href) { $links[] = $html->link($href); } - return implode('<br />', $links); + return implode('<br />', $links); } /** @@ -144,22 +142,21 @@ class Href implements Element, HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $hrefs = []; - foreach ((array)$reader->parseInnerTree() as $elem) { - if ($elem['name'] !== '{DAV:}href') + foreach ((array) $reader->parseInnerTree() as $elem) { + if ('{DAV:}href' !== $elem['name']) { continue; + } $hrefs[] = $elem['value']; - } if ($hrefs) { - return new self($hrefs, false); + return new self($hrefs); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php index 6adad3650..b5e2dae46 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Xml\Element\Sharee; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements XmlSerializable { - +class Invite implements XmlSerializable +{ /** - * A list of sharees + * A list of sharees. * * @var Sharee[] */ @@ -34,10 +36,9 @@ class Invite implements XmlSerializable { * * @param Sharee[] $sharees */ - function __construct(array $sharees) { - + public function __construct(array $sharees) + { $this->sharees = $sharees; - } /** @@ -57,14 +58,11 @@ class Invite implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->sharees as $sharee) { $writer->writeElement('{DAV:}sharee', $sharee); } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php index 00d2fa708..cb794974f 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\HTTP; /** - * LocalHref property + * LocalHref property. * * Like the Href property, this element represents {DAV:}href. The difference * is that this is used strictly for paths on the server. The LocalHref property @@ -22,10 +24,10 @@ use Sabre\HTTP; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LocalHref extends Href { - +class LocalHref extends Href +{ /** - * Constructor + * Constructor. * * You must either pass a string for a single href, or an array of hrefs. * @@ -34,15 +36,13 @@ class LocalHref extends Href { * * @param string|string[] $hrefs */ - function __construct($hrefs) { - + public function __construct($hrefs) + { parent::__construct(array_map( - function($href) { + function ($href) { return \Sabre\HTTP\encodePath($href); }, - (array)$hrefs + (array) $hrefs )); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php index f4b692219..c33812b3e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LockDiscovery.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -20,10 +22,10 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class LockDiscovery implements XmlSerializable { - +class LockDiscovery implements XmlSerializable +{ /** - * locks + * locks. * * @var LockInfo[] */ @@ -37,17 +39,16 @@ class LockDiscovery implements XmlSerializable { * * @var bool */ - static $hideLockRoot = false; + public static $hideLockRoot = false; /** - * __construct + * __construct. * * @param LockInfo[] $locks */ - function __construct($locks) { - + public function __construct($locks) + { $this->locks = $locks; - } /** @@ -63,16 +64,14 @@ class LockDiscovery implements XmlSerializable { * responsible for closing them. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->locks as $lock) { - $writer->startElement('{DAV:}activelock'); $writer->startElement('{DAV:}lockscope'); - if ($lock->scope === LockInfo::SHARED) { + if (LockInfo::SHARED === $lock->scope) { $writer->writeElement('{DAV:}shared'); } else { $writer->writeElement('{DAV:}exclusive'); @@ -86,21 +85,23 @@ class LockDiscovery implements XmlSerializable { if (!self::$hideLockRoot) { $writer->startElement('{DAV:}lockroot'); - $writer->writeElement('{DAV:}href', $writer->contextUri . $lock->uri); + $writer->writeElement('{DAV:}href', $writer->contextUri.$lock->uri); $writer->endElement(); // {DAV:}lockroot } - $writer->writeElement('{DAV:}depth', ($lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth)); - $writer->writeElement('{DAV:}timeout', 'Second-' . $lock->timeout); - - $writer->startElement('{DAV:}locktoken'); - $writer->writeElement('{DAV:}href', 'opaquelocktoken:' . $lock->token); - $writer->endElement(); // {DAV:}locktoken + $writer->writeElement('{DAV:}depth', (DAV\Server::DEPTH_INFINITY == $lock->depth ? 'infinity' : $lock->depth)); + $writer->writeElement('{DAV:}timeout', (LockInfo::TIMEOUT_INFINITE === $lock->timeout ? 'Infinite' : 'Second-'.$lock->timeout)); + + // optional according to https://tools.ietf.org/html/rfc4918#section-6.5 + if (null !== $lock->token && '' !== $lock->token) { + $writer->startElement('{DAV:}locktoken'); + $writer->writeElement('{DAV:}href', 'opaquelocktoken:'.$lock->token); + $writer->endElement(); // {DAV:}locktoken + } - $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + if ($lock->owner) { + $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner)); + } $writer->endElement(); // {DAV:}activelock - } - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php index ce640ff32..ce07d4382 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ResourceType.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -8,7 +10,7 @@ use Sabre\Xml\Element; use Sabre\Xml\Reader; /** - * {DAV:}resourcetype property + * {DAV:}resourcetype property. * * This class represents the {DAV:}resourcetype property, as defined in: * @@ -18,10 +20,10 @@ use Sabre\Xml\Reader; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ResourceType extends Element\Elements implements HtmlOutput { - +class ResourceType extends Element\Elements implements HtmlOutput +{ /** - * Constructor + * Constructor. * * You can either pass null (for no resourcetype), a string (for a single * resourcetype) or an array (for multiple). @@ -30,48 +32,44 @@ class ResourceType extends Element\Elements implements HtmlOutput { * * @param array|string|null $resourceTypes */ - function __construct($resourceTypes = null) { - - parent::__construct((array)$resourceTypes); - + public function __construct($resourceTypes = null) + { + parent::__construct((array) $resourceTypes); } /** - * Returns the values in clark-notation + * Returns the values in clark-notation. * * For example array('{DAV:}collection') * * @return array */ - function getValue() { - + public function getValue() + { return $this->value; - } /** - * Checks if the principal contains a certain value + * Checks if the principal contains a certain value. * * @param string $type + * * @return bool */ - function is($type) { - + public function is($type) + { return in_array($type, $this->value); - } /** - * Adds a resourcetype value to this property + * Adds a resourcetype value to this property. * * @param string $type - * @return void */ - function add($type) { - + public function add($type) + { $this->value[] = $type; $this->value = array_unique($this->value); - } /** @@ -93,13 +91,13 @@ class ResourceType extends Element\Elements implements HtmlOutput { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { return new self(parent::xmlDeserialize($reader)); - } /** @@ -114,15 +112,14 @@ class ResourceType extends Element\Elements implements HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php index 939062f76..95175053a 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Exception\BadRequest; @@ -22,10 +24,10 @@ use Sabre\Xml\Writer; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ShareAccess implements Element { - +class ShareAccess implements Element +{ /** - * Either SHARED or SHAREDOWNER + * Either SHARED or SHAREDOWNER. * * @var int */ @@ -39,10 +41,9 @@ class ShareAccess implements Element { * * @param int $shareAccess */ - function __construct($shareAccess) { - + public function __construct($shareAccess) + { $this->value = $shareAccess; - } /** @@ -50,10 +51,9 @@ class ShareAccess implements Element { * * @return int */ - function getValue() { - + public function getValue() + { return $this->value; - } /** @@ -73,30 +73,26 @@ class ShareAccess implements Element { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { switch ($this->value) { - - case SharingPlugin::ACCESS_NOTSHARED : + case SharingPlugin::ACCESS_NOTSHARED: $writer->writeElement('{DAV:}not-shared'); break; - case SharingPlugin::ACCESS_SHAREDOWNER : + case SharingPlugin::ACCESS_SHAREDOWNER: $writer->writeElement('{DAV:}shared-owner'); break; - case SharingPlugin::ACCESS_READ : + case SharingPlugin::ACCESS_READ: $writer->writeElement('{DAV:}read'); break; - case SharingPlugin::ACCESS_READWRITE : + case SharingPlugin::ACCESS_READWRITE: $writer->writeElement('{DAV:}read-write'); break; - case SharingPlugin::ACCESS_NOACCESS : + case SharingPlugin::ACCESS_NOACCESS: $writer->writeElement('{DAV:}no-access'); break; - } - } /** @@ -118,26 +114,26 @@ class ShareAccess implements Element { * the next element. * * @param Reader $reader + * * @return mixed */ - static function xmlDeserialize(Reader $reader) { - + public static function xmlDeserialize(Reader $reader) + { $elems = $reader->parseInnerTree(); foreach ($elems as $elem) { switch ($elem['name']) { - case '{DAV:}not-shared' : + case '{DAV:}not-shared': return new self(SharingPlugin::ACCESS_NOTSHARED); - case '{DAV:}shared-owner' : + case '{DAV:}shared-owner': return new self(SharingPlugin::ACCESS_SHAREDOWNER); - case '{DAV:}read' : + case '{DAV:}read': return new self(SharingPlugin::ACCESS_READ); - case '{DAV:}read-write' : + case '{DAV:}read-write': return new self(SharingPlugin::ACCESS_READWRITE); - case '{DAV:}no-access' : + case '{DAV:}no-access': return new self(SharingPlugin::ACCESS_NOACCESS); } } throw new BadRequest('Invalid value for {DAV:}share-access element'); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php index 677fdde4b..26e7d646e 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedLock.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\Xml\Writer; @@ -18,8 +20,8 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedLock implements XmlSerializable { - +class SupportedLock implements XmlSerializable +{ /** * The xmlSerialize method is called during xml writing. * @@ -37,18 +39,16 @@ class SupportedLock implements XmlSerializable { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { $writer->writeElement('{DAV:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}exclusive' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); $writer->writeElement('{DAV:}lockentry', [ '{DAV:}lockscope' => ['{DAV:}shared' => null], - '{DAV:}locktype' => ['{DAV:}write' => null], + '{DAV:}locktype' => ['{DAV:}write' => null], ]); - } } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php index 1a3878ef7..06ab28c94 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedMethodSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV\Browser\HtmlOutput; @@ -20,24 +22,23 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedMethodSet implements XmlSerializable, HtmlOutput { - +class SupportedMethodSet implements XmlSerializable, HtmlOutput +{ /** - * List of methods + * List of methods. * * @var string[] */ protected $methods = []; /** - * Creates the property + * Creates the property. * * @param string[] $methods */ - function __construct(array $methods) { - + public function __construct(array $methods) + { $this->methods = $methods; - } /** @@ -45,25 +46,24 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->methods; - } /** * Returns true or false if the property contains a specific method. * * @param string $methodName + * * @return bool */ - function has($methodName) { - + public function has($methodName) + { return in_array( $methodName, $this->methods ); - } /** @@ -83,16 +83,14 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-method'); $writer->writeAttribute('name', $val); $writer->endElement(); } - } /** @@ -107,15 +105,14 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'h'], $this->getValue()) ); - } - } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php index 96383ec96..4c25d23d9 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/SupportedReportSet.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Xml\Property; use Sabre\DAV; @@ -21,17 +23,17 @@ use Sabre\Xml\XmlSerializable; * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://sabre.io/license/ Modified BSD License */ -class SupportedReportSet implements XmlSerializable, HtmlOutput { - +class SupportedReportSet implements XmlSerializable, HtmlOutput +{ /** - * List of reports + * List of reports. * * @var array */ protected $reports = []; /** - * Creates the property + * Creates the property. * * Any reports passed in the constructor * should be valid report-types in clark-notation. @@ -40,61 +42,56 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * * @param string|string[] $reports */ - function __construct($reports = null) { - - if (!is_null($reports)) + public function __construct($reports = null) + { + if (!is_null($reports)) { $this->addReport($reports); - + } } /** - * Adds a report to this property + * Adds a report to this property. * * The report must be a string in clark-notation. * Multiple reports can be specified as an array. * * @param mixed $report - * @return void */ - function addReport($report) { - - $report = (array)$report; + public function addReport($report) + { + $report = (array) $report; foreach ($report as $r) { - - if (!preg_match('/^{([^}]*)}(.*)$/', $r)) + if (!preg_match('/^{([^}]*)}(.*)$/', $r)) { throw new DAV\Exception('Reportname must be in clark-notation'); - + } $this->reports[] = $r; - } - } /** - * Returns the list of supported reports + * Returns the list of supported reports. * * @return string[] */ - function getValue() { - + public function getValue() + { return $this->reports; - } /** * Returns true or false if the property contains a specific report. * * @param string $reportName + * * @return bool */ - function has($reportName) { - + public function has($reportName) + { return in_array( $reportName, $this->reports ); - } /** @@ -114,10 +111,9 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * If you are opening new elements, you must also close them again. * * @param Writer $writer - * @return void */ - function xmlSerialize(Writer $writer) { - + public function xmlSerialize(Writer $writer) + { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-report'); $writer->startElement('{DAV:}report'); @@ -125,7 +121,6 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { $writer->endElement(); $writer->endElement(); } - } /** @@ -140,15 +135,14 @@ class SupportedReportSet implements XmlSerializable, HtmlOutput { * be used to construct local links. * * @param HtmlOutputHelper $html + * * @return string */ - function toHtml(HtmlOutputHelper $html) { - + public function toHtml(HtmlOutputHelper $html) + { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); - } - } |