aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php')
-rw-r--r--vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php94
1 files changed, 42 insertions, 52 deletions
diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php
index 0e1c30ccf..372f62ab3 100644
--- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php
+++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAVACL\Xml\Property;
use Sabre\DAV;
@@ -25,10 +27,10 @@ use Sabre\Xml\Writer;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Acl implements Element, HtmlOutput {
-
+class Acl implements Element, HtmlOutput
+{
/**
- * List of privileges
+ * List of privileges.
*
* @var array
*/
@@ -43,7 +45,7 @@ class Acl implements Element, HtmlOutput {
protected $prefixBaseUrl;
/**
- * Constructor
+ * Constructor.
*
* This object requires a structure similar to the return value from
* Sabre\DAVACL\Plugin::getACL().
@@ -57,24 +59,22 @@ class Acl implements Element, HtmlOutput {
* will automatically be prefixed.
*
* @param array $privileges
- * @param bool $prefixBaseUrl
+ * @param bool $prefixBaseUrl
*/
- function __construct(array $privileges, $prefixBaseUrl = true) {
-
+ public function __construct(array $privileges, $prefixBaseUrl = true)
+ {
$this->privileges = $privileges;
$this->prefixBaseUrl = $prefixBaseUrl;
-
}
/**
- * Returns the list of privileges for this property
+ * Returns the list of privileges for this property.
*
* @return array
*/
- function getPrivileges() {
-
+ public function getPrivileges()
+ {
return $this->privileges;
-
}
/**
@@ -94,16 +94,12 @@ class Acl 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->privileges as $ace) {
-
$this->serializeAce($writer, $ace);
-
}
-
}
/**
@@ -118,32 +114,33 @@ class Acl implements Element, HtmlOutput {
* be used to construct local links.
*
* @param HtmlOutputHelper $html
+ *
* @return string
*/
- function toHtml(HtmlOutputHelper $html) {
-
+ public function toHtml(HtmlOutputHelper $html)
+ {
ob_start();
- echo "<table>";
- echo "<tr><th>Principal</th><th>Privilege</th><th></th></tr>";
+ echo '<table>';
+ echo '<tr><th>Principal</th><th>Privilege</th><th></th></tr>';
foreach ($this->privileges as $privilege) {
-
echo '<tr>';
// if it starts with a {, it's a special principal
- if ($privilege['principal'][0] === '{') {
+ if ('{' === $privilege['principal'][0]) {
echo '<td>', $html->xmlName($privilege['principal']), '</td>';
} else {
echo '<td>', $html->link($privilege['principal']), '</td>';
}
echo '<td>', $html->xmlName($privilege['privilege']), '</td>';
echo '<td>';
- if (!empty($privilege['protected'])) echo '(protected)';
+ if (!empty($privilege['protected'])) {
+ echo '(protected)';
+ }
echo '</td>';
echo '</tr>';
-
}
- echo "</table>";
- return ob_get_clean();
+ echo '</table>';
+ return ob_get_clean();
}
/**
@@ -165,21 +162,21 @@ class Acl implements Element, HtmlOutput {
* the next element.
*
* @param Reader $reader
+ *
* @return mixed
*/
- static function xmlDeserialize(Reader $reader) {
-
+ public static function xmlDeserialize(Reader $reader)
+ {
$elementMap = [
- '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue',
+ '{DAV:}ace' => 'Sabre\Xml\Element\KeyValue',
'{DAV:}privilege' => 'Sabre\Xml\Element\Elements',
'{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal',
];
$privileges = [];
- foreach ((array)$reader->parseInnerTree($elementMap) as $element) {
-
- if ($element['name'] !== '{DAV:}ace') {
+ foreach ((array) $reader->parseInnerTree($elementMap) as $element) {
+ if ('{DAV:}ace' !== $element['name']) {
continue;
}
$ace = $element['value'];
@@ -190,19 +187,18 @@ class Acl implements Element, HtmlOutput {
$principal = $ace['{DAV:}principal'];
switch ($principal->getType()) {
- case Principal::HREF :
+ case Principal::HREF:
$principal = $principal->getHref();
break;
- case Principal::AUTHENTICATED :
+ case Principal::AUTHENTICATED:
$principal = '{DAV:}authenticated';
break;
- case Principal::UNAUTHENTICATED :
+ case Principal::UNAUTHENTICATED:
$principal = '{DAV:}unauthenticated';
break;
- case Principal::ALL :
+ case Principal::ALL:
$principal = '{DAV:}all';
break;
-
}
$protected = array_key_exists('{DAV:}protected', $ace);
@@ -211,7 +207,7 @@ class Acl implements Element, HtmlOutput {
throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
}
foreach ($ace['{DAV:}grant'] as $elem) {
- if ($elem['name'] !== '{DAV:}privilege') {
+ if ('{DAV:}privilege' !== $elem['name']) {
continue;
}
@@ -222,34 +218,30 @@ class Acl implements Element, HtmlOutput {
'privilege' => $priv,
];
}
-
}
-
}
return new self($privileges);
-
}
/**
* Serializes a single access control entry.
*
* @param Writer $writer
- * @param array $ace
- * @return void
+ * @param array $ace
*/
- private function serializeAce(Writer $writer, array $ace) {
-
+ private function serializeAce(Writer $writer, array $ace)
+ {
$writer->startElement('{DAV:}ace');
switch ($ace['principal']) {
- case '{DAV:}authenticated' :
+ case '{DAV:}authenticated':
$principal = new Principal(Principal::AUTHENTICATED);
break;
- case '{DAV:}unauthenticated' :
+ case '{DAV:}unauthenticated':
$principal = new Principal(Principal::UNAUTHENTICATED);
break;
- case '{DAV:}all' :
+ case '{DAV:}all':
$principal = new Principal(Principal::ALL);
break;
default:
@@ -271,7 +263,5 @@ class Acl implements Element, HtmlOutput {
}
$writer->endElement(); // ace
-
}
-
}