Passed
Push — master ( 0f9b88...fa914f )
by Roeland
14:25 queued 12s
created
apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,10 +87,10 @@
 block discarded – undo
87 87
 	 * @return void
88 88
 	 */
89 89
 	public function propFind(PropFind $propFind, INode $node) {
90
-		$propFind->handle('{DAV:}supportedlock', function () {
90
+		$propFind->handle('{DAV:}supportedlock', function() {
91 91
 			return new SupportedLock(true);
92 92
 		});
93
-		$propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) {
93
+		$propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) {
94 94
 			return new LockDiscovery([]);
95 95
 		});
96 96
 	}
Please login to merge, or discard this patch.
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -47,113 +47,113 @@
 block discarded – undo
47 47
  * @package OCA\DAV\Connector\Sabre
48 48
  */
49 49
 class FakeLockerPlugin extends ServerPlugin {
50
-	/** @var \Sabre\DAV\Server */
51
-	private $server;
50
+    /** @var \Sabre\DAV\Server */
51
+    private $server;
52 52
 
53
-	/** {@inheritDoc} */
54
-	public function initialize(\Sabre\DAV\Server $server) {
55
-		$this->server = $server;
56
-		$this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1);
57
-		$this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1);
58
-		$server->on('propFind', [$this, 'propFind']);
59
-		$server->on('validateTokens', [$this, 'validateTokens']);
60
-	}
53
+    /** {@inheritDoc} */
54
+    public function initialize(\Sabre\DAV\Server $server) {
55
+        $this->server = $server;
56
+        $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1);
57
+        $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1);
58
+        $server->on('propFind', [$this, 'propFind']);
59
+        $server->on('validateTokens', [$this, 'validateTokens']);
60
+    }
61 61
 
62
-	/**
63
-	 * Indicate that we support LOCK and UNLOCK
64
-	 *
65
-	 * @param string $path
66
-	 * @return string[]
67
-	 */
68
-	public function getHTTPMethods($path) {
69
-		return [
70
-			'LOCK',
71
-			'UNLOCK',
72
-		];
73
-	}
62
+    /**
63
+     * Indicate that we support LOCK and UNLOCK
64
+     *
65
+     * @param string $path
66
+     * @return string[]
67
+     */
68
+    public function getHTTPMethods($path) {
69
+        return [
70
+            'LOCK',
71
+            'UNLOCK',
72
+        ];
73
+    }
74 74
 
75
-	/**
76
-	 * Indicate that we support locking
77
-	 *
78
-	 * @return integer[]
79
-	 */
80
-	public function getFeatures() {
81
-		return [2];
82
-	}
75
+    /**
76
+     * Indicate that we support locking
77
+     *
78
+     * @return integer[]
79
+     */
80
+    public function getFeatures() {
81
+        return [2];
82
+    }
83 83
 
84
-	/**
85
-	 * Return some dummy response for PROPFIND requests with regard to locking
86
-	 *
87
-	 * @param PropFind $propFind
88
-	 * @param INode $node
89
-	 * @return void
90
-	 */
91
-	public function propFind(PropFind $propFind, INode $node) {
92
-		$propFind->handle('{DAV:}supportedlock', function () {
93
-			return new SupportedLock(true);
94
-		});
95
-		$propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) {
96
-			return new LockDiscovery([]);
97
-		});
98
-	}
84
+    /**
85
+     * Return some dummy response for PROPFIND requests with regard to locking
86
+     *
87
+     * @param PropFind $propFind
88
+     * @param INode $node
89
+     * @return void
90
+     */
91
+    public function propFind(PropFind $propFind, INode $node) {
92
+        $propFind->handle('{DAV:}supportedlock', function () {
93
+            return new SupportedLock(true);
94
+        });
95
+        $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) {
96
+            return new LockDiscovery([]);
97
+        });
98
+    }
99 99
 
100
-	/**
101
-	 * Mark a locking token always as valid
102
-	 *
103
-	 * @param RequestInterface $request
104
-	 * @param array $conditions
105
-	 */
106
-	public function validateTokens(RequestInterface $request, &$conditions) {
107
-		foreach ($conditions as &$fileCondition) {
108
-			if (isset($fileCondition['tokens'])) {
109
-				foreach ($fileCondition['tokens'] as &$token) {
110
-					if (isset($token['token'])) {
111
-						if (substr($token['token'], 0, 16) === 'opaquelocktoken:') {
112
-							$token['validToken'] = true;
113
-						}
114
-					}
115
-				}
116
-			}
117
-		}
118
-	}
100
+    /**
101
+     * Mark a locking token always as valid
102
+     *
103
+     * @param RequestInterface $request
104
+     * @param array $conditions
105
+     */
106
+    public function validateTokens(RequestInterface $request, &$conditions) {
107
+        foreach ($conditions as &$fileCondition) {
108
+            if (isset($fileCondition['tokens'])) {
109
+                foreach ($fileCondition['tokens'] as &$token) {
110
+                    if (isset($token['token'])) {
111
+                        if (substr($token['token'], 0, 16) === 'opaquelocktoken:') {
112
+                            $token['validToken'] = true;
113
+                        }
114
+                    }
115
+                }
116
+            }
117
+        }
118
+    }
119 119
 
120
-	/**
121
-	 * Fakes a successful LOCK
122
-	 *
123
-	 * @param RequestInterface $request
124
-	 * @param ResponseInterface $response
125
-	 * @return bool
126
-	 */
127
-	public function fakeLockProvider(RequestInterface $request,
128
-									 ResponseInterface $response) {
129
-		$lockInfo = new LockInfo();
130
-		$lockInfo->token = md5($request->getPath());
131
-		$lockInfo->uri = $request->getPath();
132
-		$lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY;
133
-		$lockInfo->timeout = 1800;
120
+    /**
121
+     * Fakes a successful LOCK
122
+     *
123
+     * @param RequestInterface $request
124
+     * @param ResponseInterface $response
125
+     * @return bool
126
+     */
127
+    public function fakeLockProvider(RequestInterface $request,
128
+                                        ResponseInterface $response) {
129
+        $lockInfo = new LockInfo();
130
+        $lockInfo->token = md5($request->getPath());
131
+        $lockInfo->uri = $request->getPath();
132
+        $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY;
133
+        $lockInfo->timeout = 1800;
134 134
 
135
-		$body = $this->server->xml->write('{DAV:}prop', [
136
-			'{DAV:}lockdiscovery' =>
137
-					new LockDiscovery([$lockInfo])
138
-		]);
135
+        $body = $this->server->xml->write('{DAV:}prop', [
136
+            '{DAV:}lockdiscovery' =>
137
+                    new LockDiscovery([$lockInfo])
138
+        ]);
139 139
 
140
-		$response->setStatus(200);
141
-		$response->setBody($body);
140
+        $response->setStatus(200);
141
+        $response->setBody($body);
142 142
 
143
-		return false;
144
-	}
143
+        return false;
144
+    }
145 145
 
146
-	/**
147
-	 * Fakes a successful LOCK
148
-	 *
149
-	 * @param RequestInterface $request
150
-	 * @param ResponseInterface $response
151
-	 * @return bool
152
-	 */
153
-	public function fakeUnlockProvider(RequestInterface $request,
154
-									 ResponseInterface $response) {
155
-		$response->setStatus(204);
156
-		$response->setHeader('Content-Length', '0');
157
-		return false;
158
-	}
146
+    /**
147
+     * Fakes a successful LOCK
148
+     *
149
+     * @param RequestInterface $request
150
+     * @param ResponseInterface $response
151
+     * @return bool
152
+     */
153
+    public function fakeUnlockProvider(RequestInterface $request,
154
+                                        ResponseInterface $response) {
155
+        $response->setStatus(204);
156
+        $response->setHeader('Content-Length', '0');
157
+        return false;
158
+    }
159 159
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ChecksumList.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 	 */
65 65
 	public function xmlSerialize(Writer $writer) {
66 66
 		foreach ($this->checksums as $checksum) {
67
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
67
+			$writer->writeElement('{'.self::NS_OWNCLOUD.'}checksum', $checksum);
68 68
 		}
69 69
 	}
70 70
 }
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,40 +32,40 @@
 block discarded – undo
32 32
  * checksum name.
33 33
  */
34 34
 class ChecksumList implements XmlSerializable {
35
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
35
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
36 36
 
37
-	/** @var string[] of TYPE:CHECKSUM */
38
-	private $checksums;
37
+    /** @var string[] of TYPE:CHECKSUM */
38
+    private $checksums;
39 39
 
40
-	/**
41
-	 * @param string $checksum
42
-	 */
43
-	public function __construct($checksum) {
44
-		$this->checksums = explode(',', $checksum);
45
-	}
40
+    /**
41
+     * @param string $checksum
42
+     */
43
+    public function __construct($checksum) {
44
+        $this->checksums = explode(',', $checksum);
45
+    }
46 46
 
47
-	/**
48
-	 * The xmlSerialize metod is called during xml writing.
49
-	 *
50
-	 * Use the $writer argument to write its own xml serialization.
51
-	 *
52
-	 * An important note: do _not_ create a parent element. Any element
53
-	 * implementing XmlSerializble should only ever write what's considered
54
-	 * its 'inner xml'.
55
-	 *
56
-	 * The parent of the current element is responsible for writing a
57
-	 * containing element.
58
-	 *
59
-	 * This allows serializers to be re-used for different element names.
60
-	 *
61
-	 * If you are opening new elements, you must also close them again.
62
-	 *
63
-	 * @param Writer $writer
64
-	 * @return void
65
-	 */
66
-	public function xmlSerialize(Writer $writer) {
67
-		foreach ($this->checksums as $checksum) {
68
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
69
-		}
70
-	}
47
+    /**
48
+     * The xmlSerialize metod is called during xml writing.
49
+     *
50
+     * Use the $writer argument to write its own xml serialization.
51
+     *
52
+     * An important note: do _not_ create a parent element. Any element
53
+     * implementing XmlSerializble should only ever write what's considered
54
+     * its 'inner xml'.
55
+     *
56
+     * The parent of the current element is responsible for writing a
57
+     * containing element.
58
+     *
59
+     * This allows serializers to be re-used for different element names.
60
+     *
61
+     * If you are opening new elements, you must also close them again.
62
+     *
63
+     * @param Writer $writer
64
+     * @return void
65
+     */
66
+    public function xmlSerialize(Writer $writer) {
67
+        foreach ($this->checksums as $checksum) {
68
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
69
+        }
70
+    }
71 71
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ShareTypeList.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 			return null;
72 72
 		}
73 73
 		foreach ($tree as $elem) {
74
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
-				$shareTypes[] = (int)$elem['value'];
74
+			if ($elem['name'] === '{'.self::NS_OWNCLOUD.'}share-type') {
75
+				$shareTypes[] = (int) $elem['value'];
76 76
 			}
77 77
 		}
78 78
 		return new self($shareTypes);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function xmlSerialize(Writer $writer) {
88 88
 		foreach ($this->shareTypes as $shareType) {
89
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
89
+			$writer->writeElement('{'.self::NS_OWNCLOUD.'}share-type', $shareType);
90 90
 		}
91 91
 	}
92 92
 }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -32,61 +32,61 @@
 block discarded – undo
32 32
  * This property contains multiple "share-type" elements, each containing a share type.
33 33
  */
34 34
 class ShareTypeList implements Element {
35
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
35
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
36 36
 
37
-	/**
38
-	 * Share types
39
-	 *
40
-	 * @var int[]
41
-	 */
42
-	private $shareTypes;
37
+    /**
38
+     * Share types
39
+     *
40
+     * @var int[]
41
+     */
42
+    private $shareTypes;
43 43
 
44
-	/**
45
-	 * @param int[] $shareTypes
46
-	 */
47
-	public function __construct($shareTypes) {
48
-		$this->shareTypes = $shareTypes;
49
-	}
44
+    /**
45
+     * @param int[] $shareTypes
46
+     */
47
+    public function __construct($shareTypes) {
48
+        $this->shareTypes = $shareTypes;
49
+    }
50 50
 
51
-	/**
52
-	 * Returns the share types
53
-	 *
54
-	 * @return int[]
55
-	 */
56
-	public function getShareTypes() {
57
-		return $this->shareTypes;
58
-	}
51
+    /**
52
+     * Returns the share types
53
+     *
54
+     * @return int[]
55
+     */
56
+    public function getShareTypes() {
57
+        return $this->shareTypes;
58
+    }
59 59
 
60
-	/**
61
-	 * The deserialize method is called during xml parsing.
62
-	 *
63
-	 * @param Reader $reader
64
-	 * @return mixed
65
-	 */
66
-	public static function xmlDeserialize(Reader $reader) {
67
-		$shareTypes = [];
60
+    /**
61
+     * The deserialize method is called during xml parsing.
62
+     *
63
+     * @param Reader $reader
64
+     * @return mixed
65
+     */
66
+    public static function xmlDeserialize(Reader $reader) {
67
+        $shareTypes = [];
68 68
 
69
-		$tree = $reader->parseInnerTree();
70
-		if ($tree === null) {
71
-			return null;
72
-		}
73
-		foreach ($tree as $elem) {
74
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
-				$shareTypes[] = (int)$elem['value'];
76
-			}
77
-		}
78
-		return new self($shareTypes);
79
-	}
69
+        $tree = $reader->parseInnerTree();
70
+        if ($tree === null) {
71
+            return null;
72
+        }
73
+        foreach ($tree as $elem) {
74
+            if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
+                $shareTypes[] = (int)$elem['value'];
76
+            }
77
+        }
78
+        return new self($shareTypes);
79
+    }
80 80
 
81
-	/**
82
-	 * The xmlSerialize metod is called during xml writing.
83
-	 *
84
-	 * @param Writer $writer
85
-	 * @return void
86
-	 */
87
-	public function xmlSerialize(Writer $writer) {
88
-		foreach ($this->shareTypes as $shareType) {
89
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
90
-		}
91
-	}
81
+    /**
82
+     * The xmlSerialize metod is called during xml writing.
83
+     *
84
+     * @param Writer $writer
85
+     * @return void
86
+     */
87
+    public function xmlSerialize(Writer $writer) {
88
+        foreach ($this->shareTypes as $shareType) {
89
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
90
+        }
91
+    }
92 92
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -25,58 +25,58 @@
 block discarded – undo
25 25
 
26 26
 class Publisher implements XmlSerializable {
27 27
 
28
-	/**
29
-	 * @var string $publishUrl
30
-	 */
31
-	protected $publishUrl;
28
+    /**
29
+     * @var string $publishUrl
30
+     */
31
+    protected $publishUrl;
32 32
 
33
-	/**
34
-	 * @var boolean $isPublished
35
-	 */
36
-	protected $isPublished;
33
+    /**
34
+     * @var boolean $isPublished
35
+     */
36
+    protected $isPublished;
37 37
 
38
-	/**
39
-	 * @param string $publishUrl
40
-	 * @param boolean $isPublished
41
-	 */
42
-	public function __construct($publishUrl, $isPublished) {
43
-		$this->publishUrl = $publishUrl;
44
-		$this->isPublished = $isPublished;
45
-	}
38
+    /**
39
+     * @param string $publishUrl
40
+     * @param boolean $isPublished
41
+     */
42
+    public function __construct($publishUrl, $isPublished) {
43
+        $this->publishUrl = $publishUrl;
44
+        $this->isPublished = $isPublished;
45
+    }
46 46
 
47
-	/**
48
-	 * @return string
49
-	 */
50
-	public function getValue() {
51
-		return $this->publishUrl;
52
-	}
47
+    /**
48
+     * @return string
49
+     */
50
+    public function getValue() {
51
+        return $this->publishUrl;
52
+    }
53 53
 
54
-	/**
55
-	 * The xmlSerialize metod is called during xml writing.
56
-	 *
57
-	 * Use the $writer argument to write its own xml serialization.
58
-	 *
59
-	 * An important note: do _not_ create a parent element. Any element
60
-	 * implementing XmlSerializble should only ever write what's considered
61
-	 * its 'inner xml'.
62
-	 *
63
-	 * The parent of the current element is responsible for writing a
64
-	 * containing element.
65
-	 *
66
-	 * This allows serializers to be re-used for different element names.
67
-	 *
68
-	 * If you are opening new elements, you must also close them again.
69
-	 *
70
-	 * @param Writer $writer
71
-	 * @return void
72
-	 */
73
-	public function xmlSerialize(Writer $writer) {
74
-		if (!$this->isPublished) {
75
-			// for pre-publish-url
76
-			$writer->write($this->publishUrl);
77
-		} else {
78
-			// for publish-url
79
-			$writer->writeElement('{DAV:}href', $this->publishUrl);
80
-		}
81
-	}
54
+    /**
55
+     * The xmlSerialize metod is called during xml writing.
56
+     *
57
+     * Use the $writer argument to write its own xml serialization.
58
+     *
59
+     * An important note: do _not_ create a parent element. Any element
60
+     * implementing XmlSerializble should only ever write what's considered
61
+     * its 'inner xml'.
62
+     *
63
+     * The parent of the current element is responsible for writing a
64
+     * containing element.
65
+     *
66
+     * This allows serializers to be re-used for different element names.
67
+     *
68
+     * If you are opening new elements, you must also close them again.
69
+     *
70
+     * @param Writer $writer
71
+     * @return void
72
+     */
73
+    public function xmlSerialize(Writer $writer) {
74
+        if (!$this->isPublished) {
75
+            // for pre-publish-url
76
+            $writer->write($this->publishUrl);
77
+        } else {
78
+            // for publish-url
79
+            $writer->writeElement('{DAV:}href', $this->publishUrl);
80
+        }
81
+    }
82 82
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/PublicCalendarObject.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
 
24 24
 class PublicCalendarObject extends CalendarObject {
25 25
 
26
-	/**
27
-	 * public calendars are always shared
28
-	 * @return bool
29
-	 */
30
-	protected function isShared() {
31
-		return true;
32
-	}
26
+    /**
27
+     * public calendars are always shared
28
+     * @return bool
29
+     */
30
+    protected function isShared() {
31
+        return true;
32
+    }
33 33
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,17 +27,17 @@
 block discarded – undo
27 27
 
28 28
 class SearchTermFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	public static function xmlDeserialize(Reader $reader) {
36
-		$value = $reader->parseInnerTree();
37
-		if (!is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
39
-		}
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    public static function xmlDeserialize(Reader $reader) {
36
+        $value = $reader->parseInnerTree();
37
+        if (!is_string($value)) {
38
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
39
+        }
40 40
 
41
-		return $value;
42
-	}
41
+        return $value;
42
+    }
43 43
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	public static function xmlDeserialize(Reader $reader) {
36 36
 		$value = $reader->parseInnerTree();
37 37
 		if (!is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
38
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}search-term has illegal value');
39 39
 		}
40 40
 
41 41
 		return $value;
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsObjectMappingCollection.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 			$tags = $this->tagManager->getTagsByIds([$tagId]);
95 95
 			$tag = current($tags);
96 96
 			if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
97
-				throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
97
+				throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign');
98 98
 			}
99 99
 			if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
100
-				throw new Forbidden('No permission to assign tag ' . $tagId);
100
+				throw new Forbidden('No permission to assign tag '.$tagId);
101 101
 			}
102 102
 
103 103
 			$this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
104 104
 		} catch (TagNotFoundException $e) {
105
-			throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
105
+			throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign');
106 106
 		}
107 107
 	}
108 108
 
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 					return $this->makeNode($tag);
120 120
 				}
121 121
 			}
122
-			throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
122
+			throw new NotFound('Tag with id '.$tagId.' not present for object '.$this->objectId);
123 123
 		} catch (\InvalidArgumentException $e) {
124 124
 			throw new BadRequest('Invalid tag id', 0, $e);
125 125
 		} catch (TagNotFoundException $e) {
126
-			throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
126
+			throw new NotFound('Tag with id '.$tagId.' not found', 0, $e);
127 127
 		}
128 128
 	}
129 129
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		$tags = $this->tagManager->getTagsByIds($tagIds);
136 136
 
137 137
 		// filter out non-visible tags
138
-		$tags = array_filter($tags, function ($tag) {
138
+		$tags = array_filter($tags, function($tag) {
139 139
 			return $this->tagManager->canUserSeeTag($tag, $this->user);
140 140
 		});
141 141
 
142
-		return array_values(array_map(function ($tag) {
142
+		return array_values(array_map(function($tag) {
143 143
 			return $this->makeNode($tag);
144 144
 		}, $tags));
145 145
 	}
Please login to merge, or discard this patch.
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -41,169 +41,169 @@
 block discarded – undo
41 41
  */
42 42
 class SystemTagsObjectMappingCollection implements ICollection {
43 43
 
44
-	/**
45
-	 * @var string
46
-	 */
47
-	private $objectId;
48
-
49
-	/**
50
-	 * @var string
51
-	 */
52
-	private $objectType;
53
-
54
-	/**
55
-	 * @var ISystemTagManager
56
-	 */
57
-	private $tagManager;
58
-
59
-	/**
60
-	 * @var ISystemTagObjectMapper
61
-	 */
62
-	private $tagMapper;
63
-
64
-	/**
65
-	 * User
66
-	 *
67
-	 * @var IUser
68
-	 */
69
-	private $user;
70
-
71
-
72
-	/**
73
-	 * Constructor
74
-	 *
75
-	 * @param string $objectId object id
76
-	 * @param string $objectType object type
77
-	 * @param IUser $user user
78
-	 * @param ISystemTagManager $tagManager tag manager
79
-	 * @param ISystemTagObjectMapper $tagMapper tag mapper
80
-	 */
81
-	public function __construct(
82
-		$objectId,
83
-		$objectType,
84
-		IUser $user,
85
-		ISystemTagManager $tagManager,
86
-		ISystemTagObjectMapper $tagMapper
87
-	) {
88
-		$this->tagManager = $tagManager;
89
-		$this->tagMapper = $tagMapper;
90
-		$this->objectId = $objectId;
91
-		$this->objectType = $objectType;
92
-		$this->user = $user;
93
-	}
94
-
95
-	public function createFile($tagId, $data = null) {
96
-		try {
97
-			$tags = $this->tagManager->getTagsByIds([$tagId]);
98
-			$tag = current($tags);
99
-			if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
100
-				throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
101
-			}
102
-			if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
103
-				throw new Forbidden('No permission to assign tag ' . $tagId);
104
-			}
105
-
106
-			$this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
107
-		} catch (TagNotFoundException $e) {
108
-			throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
109
-		}
110
-	}
111
-
112
-	public function createDirectory($name) {
113
-		throw new Forbidden('Permission denied to create collections');
114
-	}
115
-
116
-	public function getChild($tagId) {
117
-		try {
118
-			if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) {
119
-				$tag = $this->tagManager->getTagsByIds([$tagId]);
120
-				$tag = current($tag);
121
-				if ($this->tagManager->canUserSeeTag($tag, $this->user)) {
122
-					return $this->makeNode($tag);
123
-				}
124
-			}
125
-			throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
126
-		} catch (\InvalidArgumentException $e) {
127
-			throw new BadRequest('Invalid tag id', 0, $e);
128
-		} catch (TagNotFoundException $e) {
129
-			throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
130
-		}
131
-	}
132
-
133
-	public function getChildren() {
134
-		$tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType));
135
-		if (empty($tagIds)) {
136
-			return [];
137
-		}
138
-		$tags = $this->tagManager->getTagsByIds($tagIds);
139
-
140
-		// filter out non-visible tags
141
-		$tags = array_filter($tags, function ($tag) {
142
-			return $this->tagManager->canUserSeeTag($tag, $this->user);
143
-		});
144
-
145
-		return array_values(array_map(function ($tag) {
146
-			return $this->makeNode($tag);
147
-		}, $tags));
148
-	}
149
-
150
-	public function childExists($tagId) {
151
-		try {
152
-			$result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true);
153
-
154
-			if ($result) {
155
-				$tags = $this->tagManager->getTagsByIds([$tagId]);
156
-				$tag = current($tags);
157
-				if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
158
-					return false;
159
-				}
160
-			}
161
-
162
-			return $result;
163
-		} catch (\InvalidArgumentException $e) {
164
-			throw new BadRequest('Invalid tag id', 0, $e);
165
-		} catch (TagNotFoundException $e) {
166
-			return false;
167
-		}
168
-	}
169
-
170
-	public function delete() {
171
-		throw new Forbidden('Permission denied to delete this collection');
172
-	}
173
-
174
-	public function getName() {
175
-		return $this->objectId;
176
-	}
177
-
178
-	public function setName($name) {
179
-		throw new Forbidden('Permission denied to rename this collection');
180
-	}
181
-
182
-	/**
183
-	 * Returns the last modification time, as a unix timestamp
184
-	 *
185
-	 * @return int
186
-	 */
187
-	public function getLastModified() {
188
-		return null;
189
-	}
190
-
191
-	/**
192
-	 * Create a sabre node for the mapping of the
193
-	 * given system tag to the collection's object
194
-	 *
195
-	 * @param ISystemTag $tag
196
-	 *
197
-	 * @return SystemTagMappingNode
198
-	 */
199
-	private function makeNode(ISystemTag $tag) {
200
-		return new SystemTagMappingNode(
201
-			$tag,
202
-			$this->objectId,
203
-			$this->objectType,
204
-			$this->user,
205
-			$this->tagManager,
206
-			$this->tagMapper
207
-		);
208
-	}
44
+    /**
45
+     * @var string
46
+     */
47
+    private $objectId;
48
+
49
+    /**
50
+     * @var string
51
+     */
52
+    private $objectType;
53
+
54
+    /**
55
+     * @var ISystemTagManager
56
+     */
57
+    private $tagManager;
58
+
59
+    /**
60
+     * @var ISystemTagObjectMapper
61
+     */
62
+    private $tagMapper;
63
+
64
+    /**
65
+     * User
66
+     *
67
+     * @var IUser
68
+     */
69
+    private $user;
70
+
71
+
72
+    /**
73
+     * Constructor
74
+     *
75
+     * @param string $objectId object id
76
+     * @param string $objectType object type
77
+     * @param IUser $user user
78
+     * @param ISystemTagManager $tagManager tag manager
79
+     * @param ISystemTagObjectMapper $tagMapper tag mapper
80
+     */
81
+    public function __construct(
82
+        $objectId,
83
+        $objectType,
84
+        IUser $user,
85
+        ISystemTagManager $tagManager,
86
+        ISystemTagObjectMapper $tagMapper
87
+    ) {
88
+        $this->tagManager = $tagManager;
89
+        $this->tagMapper = $tagMapper;
90
+        $this->objectId = $objectId;
91
+        $this->objectType = $objectType;
92
+        $this->user = $user;
93
+    }
94
+
95
+    public function createFile($tagId, $data = null) {
96
+        try {
97
+            $tags = $this->tagManager->getTagsByIds([$tagId]);
98
+            $tag = current($tags);
99
+            if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
100
+                throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
101
+            }
102
+            if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
103
+                throw new Forbidden('No permission to assign tag ' . $tagId);
104
+            }
105
+
106
+            $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
107
+        } catch (TagNotFoundException $e) {
108
+            throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
109
+        }
110
+    }
111
+
112
+    public function createDirectory($name) {
113
+        throw new Forbidden('Permission denied to create collections');
114
+    }
115
+
116
+    public function getChild($tagId) {
117
+        try {
118
+            if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) {
119
+                $tag = $this->tagManager->getTagsByIds([$tagId]);
120
+                $tag = current($tag);
121
+                if ($this->tagManager->canUserSeeTag($tag, $this->user)) {
122
+                    return $this->makeNode($tag);
123
+                }
124
+            }
125
+            throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
126
+        } catch (\InvalidArgumentException $e) {
127
+            throw new BadRequest('Invalid tag id', 0, $e);
128
+        } catch (TagNotFoundException $e) {
129
+            throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
130
+        }
131
+    }
132
+
133
+    public function getChildren() {
134
+        $tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType));
135
+        if (empty($tagIds)) {
136
+            return [];
137
+        }
138
+        $tags = $this->tagManager->getTagsByIds($tagIds);
139
+
140
+        // filter out non-visible tags
141
+        $tags = array_filter($tags, function ($tag) {
142
+            return $this->tagManager->canUserSeeTag($tag, $this->user);
143
+        });
144
+
145
+        return array_values(array_map(function ($tag) {
146
+            return $this->makeNode($tag);
147
+        }, $tags));
148
+    }
149
+
150
+    public function childExists($tagId) {
151
+        try {
152
+            $result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true);
153
+
154
+            if ($result) {
155
+                $tags = $this->tagManager->getTagsByIds([$tagId]);
156
+                $tag = current($tags);
157
+                if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
158
+                    return false;
159
+                }
160
+            }
161
+
162
+            return $result;
163
+        } catch (\InvalidArgumentException $e) {
164
+            throw new BadRequest('Invalid tag id', 0, $e);
165
+        } catch (TagNotFoundException $e) {
166
+            return false;
167
+        }
168
+    }
169
+
170
+    public function delete() {
171
+        throw new Forbidden('Permission denied to delete this collection');
172
+    }
173
+
174
+    public function getName() {
175
+        return $this->objectId;
176
+    }
177
+
178
+    public function setName($name) {
179
+        throw new Forbidden('Permission denied to rename this collection');
180
+    }
181
+
182
+    /**
183
+     * Returns the last modification time, as a unix timestamp
184
+     *
185
+     * @return int
186
+     */
187
+    public function getLastModified() {
188
+        return null;
189
+    }
190
+
191
+    /**
192
+     * Create a sabre node for the mapping of the
193
+     * given system tag to the collection's object
194
+     *
195
+     * @param ISystemTag $tag
196
+     *
197
+     * @return SystemTagMappingNode
198
+     */
199
+    private function makeNode(ISystemTag $tag) {
200
+        return new SystemTagMappingNode(
201
+            $tag,
202
+            $this->objectId,
203
+            $this->objectType,
204
+            $this->user,
205
+            $this->tagManager,
206
+            $this->tagMapper
207
+        );
208
+    }
209 209
 }
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsByIdCollection.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -35,144 +35,144 @@
 block discarded – undo
35 35
 
36 36
 class SystemTagsByIdCollection implements ICollection {
37 37
 
38
-	/**
39
-	 * @var ISystemTagManager
40
-	 */
41
-	private $tagManager;
42
-
43
-	/**
44
-	 * @var IGroupManager
45
-	 */
46
-	private $groupManager;
47
-
48
-	/**
49
-	 * @var IUserSession
50
-	 */
51
-	private $userSession;
52
-
53
-	/**
54
-	 * SystemTagsByIdCollection constructor.
55
-	 *
56
-	 * @param ISystemTagManager $tagManager
57
-	 * @param IUserSession $userSession
58
-	 * @param IGroupManager $groupManager
59
-	 */
60
-	public function __construct(
61
-		ISystemTagManager $tagManager,
62
-		IUserSession $userSession,
63
-		IGroupManager $groupManager
64
-	) {
65
-		$this->tagManager = $tagManager;
66
-		$this->userSession = $userSession;
67
-		$this->groupManager = $groupManager;
68
-	}
69
-
70
-	/**
71
-	 * Returns whether the currently logged in user is an administrator
72
-	 *
73
-	 * @return bool true if the user is an admin
74
-	 */
75
-	private function isAdmin() {
76
-		$user = $this->userSession->getUser();
77
-		if ($user !== null) {
78
-			return $this->groupManager->isAdmin($user->getUID());
79
-		}
80
-		return false;
81
-	}
82
-
83
-	/**
84
-	 * @param string $name
85
-	 * @param resource|string $data Initial payload
86
-	 * @throws Forbidden
87
-	 */
88
-	public function createFile($name, $data = null) {
89
-		throw new Forbidden('Cannot create tags by id');
90
-	}
91
-
92
-	/**
93
-	 * @param string $name
94
-	 */
95
-	public function createDirectory($name) {
96
-		throw new Forbidden('Permission denied to create collections');
97
-	}
98
-
99
-	/**
100
-	 * @param string $name
101
-	 */
102
-	public function getChild($name) {
103
-		try {
104
-			$tag = $this->tagManager->getTagsByIds([$name]);
105
-			$tag = current($tag);
106
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
-				throw new NotFound('Tag with id ' . $name . ' not found');
108
-			}
109
-			return $this->makeNode($tag);
110
-		} catch (\InvalidArgumentException $e) {
111
-			throw new BadRequest('Invalid tag id', 0, $e);
112
-		} catch (TagNotFoundException $e) {
113
-			throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
114
-		}
115
-	}
116
-
117
-	public function getChildren() {
118
-		$visibilityFilter = true;
119
-		if ($this->isAdmin()) {
120
-			$visibilityFilter = null;
121
-		}
122
-
123
-		$tags = $this->tagManager->getAllTags($visibilityFilter);
124
-		return array_map(function ($tag) {
125
-			return $this->makeNode($tag);
126
-		}, $tags);
127
-	}
128
-
129
-	/**
130
-	 * @param string $name
131
-	 */
132
-	public function childExists($name) {
133
-		try {
134
-			$tag = $this->tagManager->getTagsByIds([$name]);
135
-			$tag = current($tag);
136
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
137
-				return false;
138
-			}
139
-			return true;
140
-		} catch (\InvalidArgumentException $e) {
141
-			throw new BadRequest('Invalid tag id', 0, $e);
142
-		} catch (TagNotFoundException $e) {
143
-			return false;
144
-		}
145
-	}
146
-
147
-	public function delete() {
148
-		throw new Forbidden('Permission denied to delete this collection');
149
-	}
150
-
151
-	public function getName() {
152
-		return 'systemtags';
153
-	}
154
-
155
-	public function setName($name) {
156
-		throw new Forbidden('Permission denied to rename this collection');
157
-	}
158
-
159
-	/**
160
-	 * Returns the last modification time, as a unix timestamp
161
-	 *
162
-	 * @return int
163
-	 */
164
-	public function getLastModified() {
165
-		return null;
166
-	}
167
-
168
-	/**
169
-	 * Create a sabre node for the given system tag
170
-	 *
171
-	 * @param ISystemTag $tag
172
-	 *
173
-	 * @return SystemTagNode
174
-	 */
175
-	private function makeNode(ISystemTag $tag) {
176
-		return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager);
177
-	}
38
+    /**
39
+     * @var ISystemTagManager
40
+     */
41
+    private $tagManager;
42
+
43
+    /**
44
+     * @var IGroupManager
45
+     */
46
+    private $groupManager;
47
+
48
+    /**
49
+     * @var IUserSession
50
+     */
51
+    private $userSession;
52
+
53
+    /**
54
+     * SystemTagsByIdCollection constructor.
55
+     *
56
+     * @param ISystemTagManager $tagManager
57
+     * @param IUserSession $userSession
58
+     * @param IGroupManager $groupManager
59
+     */
60
+    public function __construct(
61
+        ISystemTagManager $tagManager,
62
+        IUserSession $userSession,
63
+        IGroupManager $groupManager
64
+    ) {
65
+        $this->tagManager = $tagManager;
66
+        $this->userSession = $userSession;
67
+        $this->groupManager = $groupManager;
68
+    }
69
+
70
+    /**
71
+     * Returns whether the currently logged in user is an administrator
72
+     *
73
+     * @return bool true if the user is an admin
74
+     */
75
+    private function isAdmin() {
76
+        $user = $this->userSession->getUser();
77
+        if ($user !== null) {
78
+            return $this->groupManager->isAdmin($user->getUID());
79
+        }
80
+        return false;
81
+    }
82
+
83
+    /**
84
+     * @param string $name
85
+     * @param resource|string $data Initial payload
86
+     * @throws Forbidden
87
+     */
88
+    public function createFile($name, $data = null) {
89
+        throw new Forbidden('Cannot create tags by id');
90
+    }
91
+
92
+    /**
93
+     * @param string $name
94
+     */
95
+    public function createDirectory($name) {
96
+        throw new Forbidden('Permission denied to create collections');
97
+    }
98
+
99
+    /**
100
+     * @param string $name
101
+     */
102
+    public function getChild($name) {
103
+        try {
104
+            $tag = $this->tagManager->getTagsByIds([$name]);
105
+            $tag = current($tag);
106
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
+                throw new NotFound('Tag with id ' . $name . ' not found');
108
+            }
109
+            return $this->makeNode($tag);
110
+        } catch (\InvalidArgumentException $e) {
111
+            throw new BadRequest('Invalid tag id', 0, $e);
112
+        } catch (TagNotFoundException $e) {
113
+            throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
114
+        }
115
+    }
116
+
117
+    public function getChildren() {
118
+        $visibilityFilter = true;
119
+        if ($this->isAdmin()) {
120
+            $visibilityFilter = null;
121
+        }
122
+
123
+        $tags = $this->tagManager->getAllTags($visibilityFilter);
124
+        return array_map(function ($tag) {
125
+            return $this->makeNode($tag);
126
+        }, $tags);
127
+    }
128
+
129
+    /**
130
+     * @param string $name
131
+     */
132
+    public function childExists($name) {
133
+        try {
134
+            $tag = $this->tagManager->getTagsByIds([$name]);
135
+            $tag = current($tag);
136
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
137
+                return false;
138
+            }
139
+            return true;
140
+        } catch (\InvalidArgumentException $e) {
141
+            throw new BadRequest('Invalid tag id', 0, $e);
142
+        } catch (TagNotFoundException $e) {
143
+            return false;
144
+        }
145
+    }
146
+
147
+    public function delete() {
148
+        throw new Forbidden('Permission denied to delete this collection');
149
+    }
150
+
151
+    public function getName() {
152
+        return 'systemtags';
153
+    }
154
+
155
+    public function setName($name) {
156
+        throw new Forbidden('Permission denied to rename this collection');
157
+    }
158
+
159
+    /**
160
+     * Returns the last modification time, as a unix timestamp
161
+     *
162
+     * @return int
163
+     */
164
+    public function getLastModified() {
165
+        return null;
166
+    }
167
+
168
+    /**
169
+     * Create a sabre node for the given system tag
170
+     *
171
+     * @param ISystemTag $tag
172
+     *
173
+     * @return SystemTagNode
174
+     */
175
+    private function makeNode(ISystemTag $tag) {
176
+        return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager);
177
+    }
178 178
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 			$tag = $this->tagManager->getTagsByIds([$name]);
105 105
 			$tag = current($tag);
106 106
 			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
-				throw new NotFound('Tag with id ' . $name . ' not found');
107
+				throw new NotFound('Tag with id '.$name.' not found');
108 108
 			}
109 109
 			return $this->makeNode($tag);
110 110
 		} catch (\InvalidArgumentException $e) {
111 111
 			throw new BadRequest('Invalid tag id', 0, $e);
112 112
 		} catch (TagNotFoundException $e) {
113
-			throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
113
+			throw new NotFound('Tag with id '.$name.' not found', 0, $e);
114 114
 		}
115 115
 	}
116 116
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		}
122 122
 
123 123
 		$tags = $this->tagManager->getAllTags($visibilityFilter);
124
-		return array_map(function ($tag) {
124
+		return array_map(function($tag) {
125 125
 			return $this->makeNode($tag);
126 126
 		}, $tags);
127 127
 	}
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -38,136 +38,136 @@
 block discarded – undo
38 38
  */
39 39
 class SystemTagsObjectTypeCollection implements ICollection {
40 40
 
41
-	/**
42
-	 * @var string
43
-	 */
44
-	private $objectType;
45
-
46
-	/**
47
-	 * @var ISystemTagManager
48
-	 */
49
-	private $tagManager;
50
-
51
-	/**
52
-	 * @var ISystemTagObjectMapper
53
-	 */
54
-	private $tagMapper;
55
-
56
-	/**
57
-	 * @var IGroupManager
58
-	 */
59
-	private $groupManager;
60
-
61
-	/**
62
-	 * @var IUserSession
63
-	 */
64
-	private $userSession;
65
-
66
-	/**
67
-	 * @var \Closure
68
-	 **/
69
-	protected $childExistsFunction;
70
-
71
-	/**
72
-	 * Constructor
73
-	 *
74
-	 * @param string $objectType object type
75
-	 * @param ISystemTagManager $tagManager
76
-	 * @param ISystemTagObjectMapper $tagMapper
77
-	 * @param IUserSession $userSession
78
-	 * @param IGroupManager $groupManager
79
-	 * @param \Closure $childExistsFunction
80
-	 */
81
-	public function __construct(
82
-		$objectType,
83
-		ISystemTagManager $tagManager,
84
-		ISystemTagObjectMapper $tagMapper,
85
-		IUserSession $userSession,
86
-		IGroupManager $groupManager,
87
-		\Closure $childExistsFunction
88
-	) {
89
-		$this->tagManager = $tagManager;
90
-		$this->tagMapper = $tagMapper;
91
-		$this->objectType = $objectType;
92
-		$this->userSession = $userSession;
93
-		$this->groupManager = $groupManager;
94
-		$this->childExistsFunction = $childExistsFunction;
95
-	}
96
-
97
-	/**
98
-	 * @param string $name
99
-	 * @param resource|string $data Initial payload
100
-	 * @return null|string
101
-	 * @throws Forbidden
102
-	 */
103
-	public function createFile($name, $data = null) {
104
-		throw new Forbidden('Permission denied to create nodes');
105
-	}
106
-
107
-	/**
108
-	 * @param string $name
109
-	 * @throws Forbidden
110
-	 */
111
-	public function createDirectory($name) {
112
-		throw new Forbidden('Permission denied to create collections');
113
-	}
114
-
115
-	/**
116
-	 * @param string $objectId
117
-	 * @return SystemTagsObjectMappingCollection
118
-	 * @throws NotFound
119
-	 */
120
-	public function getChild($objectId) {
121
-		// make sure the object exists and is reachable
122
-		if (!$this->childExists($objectId)) {
123
-			throw new NotFound('Entity does not exist or is not available');
124
-		}
125
-		return new SystemTagsObjectMappingCollection(
126
-			$objectId,
127
-			$this->objectType,
128
-			$this->userSession->getUser(),
129
-			$this->tagManager,
130
-			$this->tagMapper
131
-		);
132
-	}
133
-
134
-	public function getChildren() {
135
-		// do not list object ids
136
-		throw new MethodNotAllowed();
137
-	}
138
-
139
-	/**
140
-	 * Checks if a child-node with the specified name exists
141
-	 *
142
-	 * @param string $name
143
-	 * @return bool
144
-	 */
145
-	public function childExists($name) {
146
-		return call_user_func($this->childExistsFunction, $name);
147
-	}
148
-
149
-	public function delete() {
150
-		throw new Forbidden('Permission denied to delete this collection');
151
-	}
152
-
153
-	public function getName() {
154
-		return $this->objectType;
155
-	}
156
-
157
-	/**
158
-	 * @param string $name
159
-	 * @throws Forbidden
160
-	 */
161
-	public function setName($name) {
162
-		throw new Forbidden('Permission denied to rename this collection');
163
-	}
164
-
165
-	/**
166
-	 * Returns the last modification time, as a unix timestamp
167
-	 *
168
-	 * @return int
169
-	 */
170
-	public function getLastModified() {
171
-		return null;
172
-	}
41
+    /**
42
+     * @var string
43
+     */
44
+    private $objectType;
45
+
46
+    /**
47
+     * @var ISystemTagManager
48
+     */
49
+    private $tagManager;
50
+
51
+    /**
52
+     * @var ISystemTagObjectMapper
53
+     */
54
+    private $tagMapper;
55
+
56
+    /**
57
+     * @var IGroupManager
58
+     */
59
+    private $groupManager;
60
+
61
+    /**
62
+     * @var IUserSession
63
+     */
64
+    private $userSession;
65
+
66
+    /**
67
+     * @var \Closure
68
+     **/
69
+    protected $childExistsFunction;
70
+
71
+    /**
72
+     * Constructor
73
+     *
74
+     * @param string $objectType object type
75
+     * @param ISystemTagManager $tagManager
76
+     * @param ISystemTagObjectMapper $tagMapper
77
+     * @param IUserSession $userSession
78
+     * @param IGroupManager $groupManager
79
+     * @param \Closure $childExistsFunction
80
+     */
81
+    public function __construct(
82
+        $objectType,
83
+        ISystemTagManager $tagManager,
84
+        ISystemTagObjectMapper $tagMapper,
85
+        IUserSession $userSession,
86
+        IGroupManager $groupManager,
87
+        \Closure $childExistsFunction
88
+    ) {
89
+        $this->tagManager = $tagManager;
90
+        $this->tagMapper = $tagMapper;
91
+        $this->objectType = $objectType;
92
+        $this->userSession = $userSession;
93
+        $this->groupManager = $groupManager;
94
+        $this->childExistsFunction = $childExistsFunction;
95
+    }
96
+
97
+    /**
98
+     * @param string $name
99
+     * @param resource|string $data Initial payload
100
+     * @return null|string
101
+     * @throws Forbidden
102
+     */
103
+    public function createFile($name, $data = null) {
104
+        throw new Forbidden('Permission denied to create nodes');
105
+    }
106
+
107
+    /**
108
+     * @param string $name
109
+     * @throws Forbidden
110
+     */
111
+    public function createDirectory($name) {
112
+        throw new Forbidden('Permission denied to create collections');
113
+    }
114
+
115
+    /**
116
+     * @param string $objectId
117
+     * @return SystemTagsObjectMappingCollection
118
+     * @throws NotFound
119
+     */
120
+    public function getChild($objectId) {
121
+        // make sure the object exists and is reachable
122
+        if (!$this->childExists($objectId)) {
123
+            throw new NotFound('Entity does not exist or is not available');
124
+        }
125
+        return new SystemTagsObjectMappingCollection(
126
+            $objectId,
127
+            $this->objectType,
128
+            $this->userSession->getUser(),
129
+            $this->tagManager,
130
+            $this->tagMapper
131
+        );
132
+    }
133
+
134
+    public function getChildren() {
135
+        // do not list object ids
136
+        throw new MethodNotAllowed();
137
+    }
138
+
139
+    /**
140
+     * Checks if a child-node with the specified name exists
141
+     *
142
+     * @param string $name
143
+     * @return bool
144
+     */
145
+    public function childExists($name) {
146
+        return call_user_func($this->childExistsFunction, $name);
147
+    }
148
+
149
+    public function delete() {
150
+        throw new Forbidden('Permission denied to delete this collection');
151
+    }
152
+
153
+    public function getName() {
154
+        return $this->objectType;
155
+    }
156
+
157
+    /**
158
+     * @param string $name
159
+     * @throws Forbidden
160
+     */
161
+    public function setName($name) {
162
+        throw new Forbidden('Permission denied to rename this collection');
163
+    }
164
+
165
+    /**
166
+     * Returns the last modification time, as a unix timestamp
167
+     *
168
+     * @return int
169
+     */
170
+    public function getLastModified() {
171
+        return null;
172
+    }
173 173
 }
Please login to merge, or discard this patch.