Passed
Push — master ( 416f63...904fdf )
by Robin
31:44 queued 14:53
created
lib/public/AppFramework/Http/FileDisplayResponse.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->file = $file;
52 52
 		$this->setStatus($statusCode);
53 53
 		$this->setHeaders(array_merge($this->getHeaders(), $headers));
54
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
54
+		$this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"');
55 55
 
56 56
 		$this->setETag($file->getEtag());
57 57
 		$lastModified = new \DateTime();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function callback(IOutput $output) {
67 67
 		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
68
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
68
+			$output->setHeader('Content-Length: '.$this->file->getSize());
69 69
 			$output->setOutput($this->file->getContent());
70 70
 		}
71 71
 	}
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -31,40 +31,40 @@
 block discarded – undo
31 31
  * @since 11.0.0
32 32
  */
33 33
 class FileDisplayResponse extends Response implements ICallbackResponse {
34
-	/** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
35
-	private $file;
34
+    /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
35
+    private $file;
36 36
 
37
-	/**
38
-	 * FileDisplayResponse constructor.
39
-	 *
40
-	 * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
41
-	 * @param int $statusCode
42
-	 * @param array $headers
43
-	 * @since 11.0.0
44
-	 */
45
-	public function __construct($file, $statusCode = Http::STATUS_OK,
46
-								$headers = []) {
47
-		parent::__construct();
37
+    /**
38
+     * FileDisplayResponse constructor.
39
+     *
40
+     * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
41
+     * @param int $statusCode
42
+     * @param array $headers
43
+     * @since 11.0.0
44
+     */
45
+    public function __construct($file, $statusCode = Http::STATUS_OK,
46
+                                $headers = []) {
47
+        parent::__construct();
48 48
 
49
-		$this->file = $file;
50
-		$this->setStatus($statusCode);
51
-		$this->setHeaders(array_merge($this->getHeaders(), $headers));
52
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
49
+        $this->file = $file;
50
+        $this->setStatus($statusCode);
51
+        $this->setHeaders(array_merge($this->getHeaders(), $headers));
52
+        $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
53 53
 
54
-		$this->setETag($file->getEtag());
55
-		$lastModified = new \DateTime();
56
-		$lastModified->setTimestamp($file->getMTime());
57
-		$this->setLastModified($lastModified);
58
-	}
54
+        $this->setETag($file->getEtag());
55
+        $lastModified = new \DateTime();
56
+        $lastModified->setTimestamp($file->getMTime());
57
+        $this->setLastModified($lastModified);
58
+    }
59 59
 
60
-	/**
61
-	 * @param IOutput $output
62
-	 * @since 11.0.0
63
-	 */
64
-	public function callback(IOutput $output) {
65
-		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
66
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
67
-			$output->setOutput($this->file->getContent());
68
-		}
69
-	}
60
+    /**
61
+     * @param IOutput $output
62
+     * @since 11.0.0
63
+     */
64
+    public function callback(IOutput $output) {
65
+        if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
66
+            $output->setHeader('Content-Length: ' . $this->file->getSize());
67
+            $output->setOutput($this->file->getContent());
68
+        }
69
+    }
70 70
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Version/VersionParser.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 * @return bool
33 33
 	 */
34 34
 	private function isValidVersionString($versionString) {
35
-		return (bool)preg_match('/^[0-9.]+$/', $versionString);
35
+		return (bool) preg_match('/^[0-9.]+$/', $versionString);
36 36
 	}
37 37
 
38 38
 	/**
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -30,56 +30,56 @@
 block discarded – undo
30 30
  * @package OC\App\AppStore
31 31
  */
32 32
 class VersionParser {
33
-	/**
34
-	 * @param string $versionString
35
-	 * @return bool
36
-	 */
37
-	private function isValidVersionString($versionString) {
38
-		return (bool)preg_match('/^[0-9.]+$/', $versionString);
39
-	}
33
+    /**
34
+     * @param string $versionString
35
+     * @return bool
36
+     */
37
+    private function isValidVersionString($versionString) {
38
+        return (bool)preg_match('/^[0-9.]+$/', $versionString);
39
+    }
40 40
 
41
-	/**
42
-	 * Returns the version for a version string
43
-	 *
44
-	 * @param string $versionSpec
45
-	 * @return Version
46
-	 * @throws \Exception If the version cannot be parsed
47
-	 */
48
-	public function getVersion($versionSpec) {
49
-		// * indicates that the version is compatible with all versions
50
-		if ($versionSpec === '*') {
51
-			return new Version('', '');
52
-		}
41
+    /**
42
+     * Returns the version for a version string
43
+     *
44
+     * @param string $versionSpec
45
+     * @return Version
46
+     * @throws \Exception If the version cannot be parsed
47
+     */
48
+    public function getVersion($versionSpec) {
49
+        // * indicates that the version is compatible with all versions
50
+        if ($versionSpec === '*') {
51
+            return new Version('', '');
52
+        }
53 53
 
54
-		// Count the amount of =, if it is one then it's either maximum or minimum
55
-		// version. If it is two then it is maximum and minimum.
56
-		$versionElements = explode(' ', $versionSpec);
57
-		$firstVersion = isset($versionElements[0]) ? $versionElements[0] : '';
58
-		$firstVersionNumber = substr($firstVersion, 2);
59
-		$secondVersion = isset($versionElements[1]) ? $versionElements[1] : '';
60
-		$secondVersionNumber = substr($secondVersion, 2);
54
+        // Count the amount of =, if it is one then it's either maximum or minimum
55
+        // version. If it is two then it is maximum and minimum.
56
+        $versionElements = explode(' ', $versionSpec);
57
+        $firstVersion = isset($versionElements[0]) ? $versionElements[0] : '';
58
+        $firstVersionNumber = substr($firstVersion, 2);
59
+        $secondVersion = isset($versionElements[1]) ? $versionElements[1] : '';
60
+        $secondVersionNumber = substr($secondVersion, 2);
61 61
 
62
-		switch (count($versionElements)) {
63
-			case 1:
64
-				if (!$this->isValidVersionString($firstVersionNumber)) {
65
-					break;
66
-				}
67
-				if (strpos($firstVersion, '>') === 0) {
68
-					return new Version($firstVersionNumber, '');
69
-				}
70
-				return new Version('', $firstVersionNumber);
71
-			case 2:
72
-				if (!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) {
73
-					break;
74
-				}
75
-				return new Version($firstVersionNumber, $secondVersionNumber);
76
-		}
62
+        switch (count($versionElements)) {
63
+            case 1:
64
+                if (!$this->isValidVersionString($firstVersionNumber)) {
65
+                    break;
66
+                }
67
+                if (strpos($firstVersion, '>') === 0) {
68
+                    return new Version($firstVersionNumber, '');
69
+                }
70
+                return new Version('', $firstVersionNumber);
71
+            case 2:
72
+                if (!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) {
73
+                    break;
74
+                }
75
+                return new Version($firstVersionNumber, $secondVersionNumber);
76
+        }
77 77
 
78
-		throw new \Exception(
79
-			sprintf(
80
-				'Version cannot be parsed: %s',
81
-				$versionSpec
82
-			)
83
-		);
84
-	}
78
+        throw new \Exception(
79
+            sprintf(
80
+                'Version cannot be parsed: %s',
81
+                $versionSpec
82
+            )
83
+        );
84
+    }
85 85
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/Bundle.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,36 +24,36 @@
 block discarded – undo
24 24
 use OCP\IL10N;
25 25
 
26 26
 abstract class Bundle {
27
-	/** @var IL10N */
28
-	protected $l10n;
27
+    /** @var IL10N */
28
+    protected $l10n;
29 29
 
30
-	/**
31
-	 * @param IL10N $l10n
32
-	 */
33
-	public function __construct(IL10N $l10n) {
34
-		$this->l10n = $l10n;
35
-	}
30
+    /**
31
+     * @param IL10N $l10n
32
+     */
33
+    public function __construct(IL10N $l10n) {
34
+        $this->l10n = $l10n;
35
+    }
36 36
 
37
-	/**
38
-	 * Get the identifier of the bundle
39
-	 *
40
-	 * @return string
41
-	 */
42
-	final public function getIdentifier() {
43
-		return substr(strrchr(get_class($this), '\\'), 1);
44
-	}
37
+    /**
38
+     * Get the identifier of the bundle
39
+     *
40
+     * @return string
41
+     */
42
+    final public function getIdentifier() {
43
+        return substr(strrchr(get_class($this), '\\'), 1);
44
+    }
45 45
 
46
-	/**
47
-	 * Get the name of the bundle
48
-	 *
49
-	 * @return string
50
-	 */
51
-	abstract public function getName();
46
+    /**
47
+     * Get the name of the bundle
48
+     *
49
+     * @return string
50
+     */
51
+    abstract public function getName();
52 52
 
53
-	/**
54
-	 * Get the list of app identifiers in the bundle
55
-	 *
56
-	 * @return array
57
-	 */
58
-	abstract public function getAppIdentifiers();
53
+    /**
54
+     * Get the list of app identifiers in the bundle
55
+     *
56
+     * @return array
57
+     */
58
+    abstract public function getAppIdentifiers();
59 59
 }
Please login to merge, or discard this patch.
lib/private/Share20/LegacyHooks.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 		/** @var IShare[] $deletedShares */
67 67
 		$deletedShares = $e->getArgument('deletedShares');
68 68
 
69
-		$formattedDeletedShares = array_map(function ($share) {
69
+		$formattedDeletedShares = array_map(function($share) {
70 70
 			return $this->formatHookParams($share);
71 71
 		}, $deletedShares);
72 72
 
Please login to merge, or discard this patch.
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -33,145 +33,145 @@
 block discarded – undo
33 33
 use Symfony\Component\EventDispatcher\GenericEvent;
34 34
 
35 35
 class LegacyHooks {
36
-	/** @var EventDispatcherInterface */
37
-	private $eventDispatcher;
38
-
39
-	/**
40
-	 * LegacyHooks constructor.
41
-	 *
42
-	 * @param EventDispatcherInterface $eventDispatcher
43
-	 */
44
-	public function __construct(EventDispatcherInterface $eventDispatcher) {
45
-		$this->eventDispatcher = $eventDispatcher;
46
-
47
-		$this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
48
-		$this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
49
-		$this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
50
-		$this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
51
-		$this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
52
-	}
53
-
54
-	/**
55
-	 * @param GenericEvent $e
56
-	 */
57
-	public function preUnshare(GenericEvent $e) {
58
-		/** @var IShare $share */
59
-		$share = $e->getSubject();
60
-
61
-		$formatted = $this->formatHookParams($share);
62
-		\OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
63
-	}
64
-
65
-	/**
66
-	 * @param GenericEvent $e
67
-	 */
68
-	public function postUnshare(GenericEvent $e) {
69
-		/** @var IShare $share */
70
-		$share = $e->getSubject();
71
-
72
-		$formatted = $this->formatHookParams($share);
73
-
74
-		/** @var IShare[] $deletedShares */
75
-		$deletedShares = $e->getArgument('deletedShares');
76
-
77
-		$formattedDeletedShares = array_map(function ($share) {
78
-			return $this->formatHookParams($share);
79
-		}, $deletedShares);
80
-
81
-		$formatted['deletedShares'] = $formattedDeletedShares;
82
-
83
-		\OC_Hook::emit(Share::class, 'post_unshare', $formatted);
84
-	}
85
-
86
-	/**
87
-	 * @param GenericEvent $e
88
-	 */
89
-	public function postUnshareFromSelf(GenericEvent $e) {
90
-		/** @var IShare $share */
91
-		$share = $e->getSubject();
92
-
93
-		$formatted = $this->formatHookParams($share);
94
-		$formatted['itemTarget'] = $formatted['fileTarget'];
95
-		$formatted['unsharedItems'] = [$formatted];
96
-
97
-		\OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
98
-	}
99
-
100
-	private function formatHookParams(IShare $share) {
101
-		// Prepare hook
102
-		$shareType = $share->getShareType();
103
-		$sharedWith = '';
104
-		if ($shareType === IShare::TYPE_USER ||
105
-			$shareType === IShare::TYPE_GROUP ||
106
-			$shareType === IShare::TYPE_REMOTE) {
107
-			$sharedWith = $share->getSharedWith();
108
-		}
109
-
110
-		$hookParams = [
111
-			'id' => $share->getId(),
112
-			'itemType' => $share->getNodeType(),
113
-			'itemSource' => $share->getNodeId(),
114
-			'shareType' => $shareType,
115
-			'shareWith' => $sharedWith,
116
-			'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
117
-			'uidOwner' => $share->getSharedBy(),
118
-			'fileSource' => $share->getNodeId(),
119
-			'fileTarget' => $share->getTarget()
120
-		];
121
-		return $hookParams;
122
-	}
123
-
124
-	public function preShare(GenericEvent $e) {
125
-		/** @var IShare $share */
126
-		$share = $e->getSubject();
127
-
128
-		// Pre share hook
129
-		$run = true;
130
-		$error = '';
131
-		$preHookData = [
132
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
133
-			'itemSource' => $share->getNode()->getId(),
134
-			'shareType' => $share->getShareType(),
135
-			'uidOwner' => $share->getSharedBy(),
136
-			'permissions' => $share->getPermissions(),
137
-			'fileSource' => $share->getNode()->getId(),
138
-			'expiration' => $share->getExpirationDate(),
139
-			'token' => $share->getToken(),
140
-			'itemTarget' => $share->getTarget(),
141
-			'shareWith' => $share->getSharedWith(),
142
-			'run' => &$run,
143
-			'error' => &$error,
144
-		];
145
-		\OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
146
-
147
-		if ($run === false) {
148
-			$e->setArgument('error', $error);
149
-			$e->stopPropagation();
150
-		}
151
-
152
-		return $e;
153
-	}
154
-
155
-	public function postShare(GenericEvent $e) {
156
-		/** @var IShare $share */
157
-		$share = $e->getSubject();
158
-
159
-		$postHookData = [
160
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
161
-			'itemSource' => $share->getNode()->getId(),
162
-			'shareType' => $share->getShareType(),
163
-			'uidOwner' => $share->getSharedBy(),
164
-			'permissions' => $share->getPermissions(),
165
-			'fileSource' => $share->getNode()->getId(),
166
-			'expiration' => $share->getExpirationDate(),
167
-			'token' => $share->getToken(),
168
-			'id' => $share->getId(),
169
-			'shareWith' => $share->getSharedWith(),
170
-			'itemTarget' => $share->getTarget(),
171
-			'fileTarget' => $share->getTarget(),
172
-			'path' => $share->getNode()->getPath(),
173
-		];
174
-
175
-		\OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
-	}
36
+    /** @var EventDispatcherInterface */
37
+    private $eventDispatcher;
38
+
39
+    /**
40
+     * LegacyHooks constructor.
41
+     *
42
+     * @param EventDispatcherInterface $eventDispatcher
43
+     */
44
+    public function __construct(EventDispatcherInterface $eventDispatcher) {
45
+        $this->eventDispatcher = $eventDispatcher;
46
+
47
+        $this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
48
+        $this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
49
+        $this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
50
+        $this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
51
+        $this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
52
+    }
53
+
54
+    /**
55
+     * @param GenericEvent $e
56
+     */
57
+    public function preUnshare(GenericEvent $e) {
58
+        /** @var IShare $share */
59
+        $share = $e->getSubject();
60
+
61
+        $formatted = $this->formatHookParams($share);
62
+        \OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
63
+    }
64
+
65
+    /**
66
+     * @param GenericEvent $e
67
+     */
68
+    public function postUnshare(GenericEvent $e) {
69
+        /** @var IShare $share */
70
+        $share = $e->getSubject();
71
+
72
+        $formatted = $this->formatHookParams($share);
73
+
74
+        /** @var IShare[] $deletedShares */
75
+        $deletedShares = $e->getArgument('deletedShares');
76
+
77
+        $formattedDeletedShares = array_map(function ($share) {
78
+            return $this->formatHookParams($share);
79
+        }, $deletedShares);
80
+
81
+        $formatted['deletedShares'] = $formattedDeletedShares;
82
+
83
+        \OC_Hook::emit(Share::class, 'post_unshare', $formatted);
84
+    }
85
+
86
+    /**
87
+     * @param GenericEvent $e
88
+     */
89
+    public function postUnshareFromSelf(GenericEvent $e) {
90
+        /** @var IShare $share */
91
+        $share = $e->getSubject();
92
+
93
+        $formatted = $this->formatHookParams($share);
94
+        $formatted['itemTarget'] = $formatted['fileTarget'];
95
+        $formatted['unsharedItems'] = [$formatted];
96
+
97
+        \OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
98
+    }
99
+
100
+    private function formatHookParams(IShare $share) {
101
+        // Prepare hook
102
+        $shareType = $share->getShareType();
103
+        $sharedWith = '';
104
+        if ($shareType === IShare::TYPE_USER ||
105
+            $shareType === IShare::TYPE_GROUP ||
106
+            $shareType === IShare::TYPE_REMOTE) {
107
+            $sharedWith = $share->getSharedWith();
108
+        }
109
+
110
+        $hookParams = [
111
+            'id' => $share->getId(),
112
+            'itemType' => $share->getNodeType(),
113
+            'itemSource' => $share->getNodeId(),
114
+            'shareType' => $shareType,
115
+            'shareWith' => $sharedWith,
116
+            'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
117
+            'uidOwner' => $share->getSharedBy(),
118
+            'fileSource' => $share->getNodeId(),
119
+            'fileTarget' => $share->getTarget()
120
+        ];
121
+        return $hookParams;
122
+    }
123
+
124
+    public function preShare(GenericEvent $e) {
125
+        /** @var IShare $share */
126
+        $share = $e->getSubject();
127
+
128
+        // Pre share hook
129
+        $run = true;
130
+        $error = '';
131
+        $preHookData = [
132
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
133
+            'itemSource' => $share->getNode()->getId(),
134
+            'shareType' => $share->getShareType(),
135
+            'uidOwner' => $share->getSharedBy(),
136
+            'permissions' => $share->getPermissions(),
137
+            'fileSource' => $share->getNode()->getId(),
138
+            'expiration' => $share->getExpirationDate(),
139
+            'token' => $share->getToken(),
140
+            'itemTarget' => $share->getTarget(),
141
+            'shareWith' => $share->getSharedWith(),
142
+            'run' => &$run,
143
+            'error' => &$error,
144
+        ];
145
+        \OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
146
+
147
+        if ($run === false) {
148
+            $e->setArgument('error', $error);
149
+            $e->stopPropagation();
150
+        }
151
+
152
+        return $e;
153
+    }
154
+
155
+    public function postShare(GenericEvent $e) {
156
+        /** @var IShare $share */
157
+        $share = $e->getSubject();
158
+
159
+        $postHookData = [
160
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
161
+            'itemSource' => $share->getNode()->getId(),
162
+            'shareType' => $share->getShareType(),
163
+            'uidOwner' => $share->getSharedBy(),
164
+            'permissions' => $share->getPermissions(),
165
+            'fileSource' => $share->getNode()->getId(),
166
+            'expiration' => $share->getExpirationDate(),
167
+            'token' => $share->getToken(),
168
+            'id' => $share->getId(),
169
+            'shareWith' => $share->getSharedWith(),
170
+            'itemTarget' => $share->getTarget(),
171
+            'fileTarget' => $share->getTarget(),
172
+            'path' => $share->getNode()->getPath(),
173
+        ];
174
+
175
+        \OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
+    }
177 177
 }
Please login to merge, or discard this patch.
lib/private/Share20/Share.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function setId($id) {
88 88
 		if (is_int($id)) {
89
-			$id = (string)$id;
89
+			$id = (string) $id;
90 90
 		}
91 91
 
92 92
 		if (!is_string($id)) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		if ($this->providerId === null || $this->id === null) {
116 116
 			throw new \UnexpectedValueException;
117 117
 		}
118
-		return $this->providerId . ':' . $this->id;
118
+		return $this->providerId.':'.$this->id;
119 119
 	}
120 120
 
121 121
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 			$nodes = $userFolder->getById($this->fileId);
165 165
 			if (empty($nodes)) {
166
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
166
+				throw new NotFoundException('Node for share not found, fileid: '.$this->fileId);
167 167
 			}
168 168
 
169 169
 			$this->node = $nodes[0];
Please login to merge, or discard this patch.
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -41,583 +41,583 @@
 block discarded – undo
41 41
 use OCP\Share\IShare;
42 42
 
43 43
 class Share implements IShare {
44
-	/** @var string */
45
-	private $id;
46
-	/** @var string */
47
-	private $providerId;
48
-	/** @var Node */
49
-	private $node;
50
-	/** @var int */
51
-	private $fileId;
52
-	/** @var string */
53
-	private $nodeType;
54
-	/** @var int */
55
-	private $shareType;
56
-	/** @var string */
57
-	private $sharedWith;
58
-	/** @var string */
59
-	private $sharedWithDisplayName;
60
-	/** @var string */
61
-	private $sharedWithAvatar;
62
-	/** @var string */
63
-	private $sharedBy;
64
-	/** @var string */
65
-	private $shareOwner;
66
-	/** @var int */
67
-	private $permissions;
68
-	/** @var IAttributes */
69
-	private $attributes;
70
-	/** @var int */
71
-	private $status;
72
-	/** @var string */
73
-	private $note = '';
74
-	/** @var \DateTime */
75
-	private $expireDate;
76
-	/** @var string */
77
-	private $password;
78
-	private ?\DateTimeInterface $passwordExpirationTime = null;
79
-	/** @var bool */
80
-	private $sendPasswordByTalk = false;
81
-	/** @var string */
82
-	private $token;
83
-	/** @var int */
84
-	private $parent;
85
-	/** @var string */
86
-	private $target;
87
-	/** @var \DateTime */
88
-	private $shareTime;
89
-	/** @var bool */
90
-	private $mailSend;
91
-	/** @var string */
92
-	private $label = '';
93
-
94
-	/** @var IRootFolder */
95
-	private $rootFolder;
96
-
97
-	/** @var IUserManager */
98
-	private $userManager;
99
-
100
-	/** @var ICacheEntry|null */
101
-	private $nodeCacheEntry;
102
-
103
-	/** @var bool */
104
-	private $hideDownload = false;
105
-
106
-	public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
107
-		$this->rootFolder = $rootFolder;
108
-		$this->userManager = $userManager;
109
-	}
110
-
111
-	/**
112
-	 * @inheritdoc
113
-	 */
114
-	public function setId($id) {
115
-		if (is_int($id)) {
116
-			$id = (string)$id;
117
-		}
118
-
119
-		if (!is_string($id)) {
120
-			throw new \InvalidArgumentException('String expected.');
121
-		}
122
-
123
-		if ($this->id !== null) {
124
-			throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
125
-		}
126
-
127
-		$this->id = trim($id);
128
-		return $this;
129
-	}
130
-
131
-	/**
132
-	 * @inheritdoc
133
-	 */
134
-	public function getId() {
135
-		return $this->id;
136
-	}
137
-
138
-	/**
139
-	 * @inheritdoc
140
-	 */
141
-	public function getFullId() {
142
-		if ($this->providerId === null || $this->id === null) {
143
-			throw new \UnexpectedValueException;
144
-		}
145
-		return $this->providerId . ':' . $this->id;
146
-	}
147
-
148
-	/**
149
-	 * @inheritdoc
150
-	 */
151
-	public function setProviderId($id) {
152
-		if (!is_string($id)) {
153
-			throw new \InvalidArgumentException('String expected.');
154
-		}
155
-
156
-		if ($this->providerId !== null) {
157
-			throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
158
-		}
159
-
160
-		$this->providerId = trim($id);
161
-		return $this;
162
-	}
163
-
164
-	/**
165
-	 * @inheritdoc
166
-	 */
167
-	public function setNode(Node $node) {
168
-		$this->fileId = null;
169
-		$this->nodeType = null;
170
-		$this->node = $node;
171
-		return $this;
172
-	}
173
-
174
-	/**
175
-	 * @inheritdoc
176
-	 */
177
-	public function getNode() {
178
-		if ($this->node === null) {
179
-			if ($this->shareOwner === null || $this->fileId === null) {
180
-				throw new NotFoundException();
181
-			}
182
-
183
-			// for federated shares the owner can be a remote user, in this
184
-			// case we use the initiator
185
-			if ($this->userManager->userExists($this->shareOwner)) {
186
-				$userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
187
-			} else {
188
-				$userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
189
-			}
190
-
191
-			$nodes = $userFolder->getById($this->fileId);
192
-			if (empty($nodes)) {
193
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
194
-			}
195
-
196
-			$this->node = $nodes[0];
197
-		}
198
-
199
-		return $this->node;
200
-	}
201
-
202
-	/**
203
-	 * @inheritdoc
204
-	 */
205
-	public function setNodeId($fileId) {
206
-		$this->node = null;
207
-		$this->fileId = $fileId;
208
-		return $this;
209
-	}
210
-
211
-	/**
212
-	 * @inheritdoc
213
-	 */
214
-	public function getNodeId() {
215
-		if ($this->fileId === null) {
216
-			$this->fileId = $this->getNode()->getId();
217
-		}
218
-
219
-		return $this->fileId;
220
-	}
221
-
222
-	/**
223
-	 * @inheritdoc
224
-	 */
225
-	public function setNodeType($type) {
226
-		if ($type !== 'file' && $type !== 'folder') {
227
-			throw new \InvalidArgumentException();
228
-		}
229
-
230
-		$this->nodeType = $type;
231
-		return $this;
232
-	}
233
-
234
-	/**
235
-	 * @inheritdoc
236
-	 */
237
-	public function getNodeType() {
238
-		if ($this->nodeType === null) {
239
-			if ($this->getNodeCacheEntry()) {
240
-				$info = $this->getNodeCacheEntry();
241
-				$this->nodeType = $info->getMimeType() === FileInfo::MIMETYPE_FOLDER ? 'folder' : 'file';
242
-			} else {
243
-				$node = $this->getNode();
244
-				$this->nodeType = $node instanceof File ? 'file' : 'folder';
245
-			}
246
-		}
247
-
248
-		return $this->nodeType;
249
-	}
250
-
251
-	/**
252
-	 * @inheritdoc
253
-	 */
254
-	public function setShareType($shareType) {
255
-		$this->shareType = $shareType;
256
-		return $this;
257
-	}
258
-
259
-	/**
260
-	 * @inheritdoc
261
-	 */
262
-	public function getShareType() {
263
-		return $this->shareType;
264
-	}
265
-
266
-	/**
267
-	 * @inheritdoc
268
-	 */
269
-	public function setSharedWith($sharedWith) {
270
-		if (!is_string($sharedWith)) {
271
-			throw new \InvalidArgumentException();
272
-		}
273
-		$this->sharedWith = $sharedWith;
274
-		return $this;
275
-	}
276
-
277
-	/**
278
-	 * @inheritdoc
279
-	 */
280
-	public function getSharedWith() {
281
-		return $this->sharedWith;
282
-	}
283
-
284
-	/**
285
-	 * @inheritdoc
286
-	 */
287
-	public function setSharedWithDisplayName($displayName) {
288
-		if (!is_string($displayName)) {
289
-			throw new \InvalidArgumentException();
290
-		}
291
-		$this->sharedWithDisplayName = $displayName;
292
-		return $this;
293
-	}
294
-
295
-	/**
296
-	 * @inheritdoc
297
-	 */
298
-	public function getSharedWithDisplayName() {
299
-		return $this->sharedWithDisplayName;
300
-	}
301
-
302
-	/**
303
-	 * @inheritdoc
304
-	 */
305
-	public function setSharedWithAvatar($src) {
306
-		if (!is_string($src)) {
307
-			throw new \InvalidArgumentException();
308
-		}
309
-		$this->sharedWithAvatar = $src;
310
-		return $this;
311
-	}
312
-
313
-	/**
314
-	 * @inheritdoc
315
-	 */
316
-	public function getSharedWithAvatar() {
317
-		return $this->sharedWithAvatar;
318
-	}
319
-
320
-	/**
321
-	 * @inheritdoc
322
-	 */
323
-	public function setPermissions($permissions) {
324
-		//TODO checks
325
-
326
-		$this->permissions = $permissions;
327
-		return $this;
328
-	}
329
-
330
-	/**
331
-	 * @inheritdoc
332
-	 */
333
-	public function getPermissions() {
334
-		return $this->permissions;
335
-	}
336
-
337
-	/**
338
-	 * @inheritdoc
339
-	 */
340
-	public function newAttributes(): IAttributes {
341
-		return new ShareAttributes();
342
-	}
343
-
344
-	/**
345
-	 * @inheritdoc
346
-	 */
347
-	public function setAttributes(?IAttributes $attributes) {
348
-		$this->attributes = $attributes;
349
-		return $this;
350
-	}
351
-
352
-	/**
353
-	 * @inheritdoc
354
-	 */
355
-	public function getAttributes(): ?IAttributes {
356
-		return $this->attributes;
357
-	}
358
-
359
-	/**
360
-	 * @inheritdoc
361
-	 */
362
-	public function setStatus(int $status): IShare {
363
-		$this->status = $status;
364
-		return $this;
365
-	}
366
-
367
-	/**
368
-	 * @inheritdoc
369
-	 */
370
-	public function getStatus(): int {
371
-		return $this->status;
372
-	}
373
-
374
-	/**
375
-	 * @inheritdoc
376
-	 */
377
-	public function setNote($note) {
378
-		$this->note = $note;
379
-		return $this;
380
-	}
381
-
382
-	/**
383
-	 * @inheritdoc
384
-	 */
385
-	public function getNote() {
386
-		if (is_string($this->note)) {
387
-			return $this->note;
388
-		}
389
-		return '';
390
-	}
391
-
392
-	/**
393
-	 * @inheritdoc
394
-	 */
395
-	public function setLabel($label) {
396
-		$this->label = $label;
397
-		return $this;
398
-	}
399
-
400
-	/**
401
-	 * @inheritdoc
402
-	 */
403
-	public function getLabel() {
404
-		return $this->label;
405
-	}
406
-
407
-	/**
408
-	 * @inheritdoc
409
-	 */
410
-	public function setExpirationDate($expireDate) {
411
-		//TODO checks
412
-
413
-		$this->expireDate = $expireDate;
414
-		return $this;
415
-	}
416
-
417
-	/**
418
-	 * @inheritdoc
419
-	 */
420
-	public function getExpirationDate() {
421
-		return $this->expireDate;
422
-	}
423
-
424
-	/**
425
-	 * @inheritdoc
426
-	 */
427
-	public function isExpired() {
428
-		return $this->getExpirationDate() !== null &&
429
-			$this->getExpirationDate() <= new \DateTime();
430
-	}
431
-
432
-	/**
433
-	 * @inheritdoc
434
-	 */
435
-	public function setSharedBy($sharedBy) {
436
-		if (!is_string($sharedBy)) {
437
-			throw new \InvalidArgumentException();
438
-		}
439
-		//TODO checks
440
-		$this->sharedBy = $sharedBy;
441
-
442
-		return $this;
443
-	}
444
-
445
-	/**
446
-	 * @inheritdoc
447
-	 */
448
-	public function getSharedBy() {
449
-		//TODO check if set
450
-		return $this->sharedBy;
451
-	}
452
-
453
-	/**
454
-	 * @inheritdoc
455
-	 */
456
-	public function setShareOwner($shareOwner) {
457
-		if (!is_string($shareOwner)) {
458
-			throw new \InvalidArgumentException();
459
-		}
460
-		//TODO checks
461
-
462
-		$this->shareOwner = $shareOwner;
463
-		return $this;
464
-	}
465
-
466
-	/**
467
-	 * @inheritdoc
468
-	 */
469
-	public function getShareOwner() {
470
-		//TODO check if set
471
-		return $this->shareOwner;
472
-	}
473
-
474
-	/**
475
-	 * @inheritdoc
476
-	 */
477
-	public function setPassword($password) {
478
-		$this->password = $password;
479
-		return $this;
480
-	}
481
-
482
-	/**
483
-	 * @inheritdoc
484
-	 */
485
-	public function getPassword() {
486
-		return $this->password;
487
-	}
488
-
489
-	/**
490
-	 * @inheritdoc
491
-	 */
492
-	public function setPasswordExpirationTime(?\DateTimeInterface $passwordExpirationTime = null): IShare {
493
-		$this->passwordExpirationTime = $passwordExpirationTime;
494
-		return $this;
495
-	}
496
-
497
-	/**
498
-	 * @inheritdoc
499
-	 */
500
-	public function getPasswordExpirationTime(): ?\DateTimeInterface {
501
-		return $this->passwordExpirationTime;
502
-	}
503
-
504
-	/**
505
-	 * @inheritdoc
506
-	 */
507
-	public function setSendPasswordByTalk(bool $sendPasswordByTalk) {
508
-		$this->sendPasswordByTalk = $sendPasswordByTalk;
509
-		return $this;
510
-	}
511
-
512
-	/**
513
-	 * @inheritdoc
514
-	 */
515
-	public function getSendPasswordByTalk(): bool {
516
-		return $this->sendPasswordByTalk;
517
-	}
518
-
519
-	/**
520
-	 * @inheritdoc
521
-	 */
522
-	public function setToken($token) {
523
-		$this->token = $token;
524
-		return $this;
525
-	}
526
-
527
-	/**
528
-	 * @inheritdoc
529
-	 */
530
-	public function getToken() {
531
-		return $this->token;
532
-	}
533
-
534
-	/**
535
-	 * Set the parent of this share
536
-	 *
537
-	 * @param int parent
538
-	 * @return IShare
539
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
540
-	 */
541
-	public function setParent($parent) {
542
-		$this->parent = $parent;
543
-		return $this;
544
-	}
545
-
546
-	/**
547
-	 * Get the parent of this share.
548
-	 *
549
-	 * @return int
550
-	 * @deprecated The new shares do not have parents. This is just here for legacy reasons.
551
-	 */
552
-	public function getParent() {
553
-		return $this->parent;
554
-	}
555
-
556
-	/**
557
-	 * @inheritdoc
558
-	 */
559
-	public function setTarget($target) {
560
-		$this->target = $target;
561
-		return $this;
562
-	}
563
-
564
-	/**
565
-	 * @inheritdoc
566
-	 */
567
-	public function getTarget() {
568
-		return $this->target;
569
-	}
570
-
571
-	/**
572
-	 * @inheritdoc
573
-	 */
574
-	public function setShareTime(\DateTime $shareTime) {
575
-		$this->shareTime = $shareTime;
576
-		return $this;
577
-	}
578
-
579
-	/**
580
-	 * @inheritdoc
581
-	 */
582
-	public function getShareTime() {
583
-		return $this->shareTime;
584
-	}
585
-
586
-	/**
587
-	 * @inheritdoc
588
-	 */
589
-	public function setMailSend($mailSend) {
590
-		$this->mailSend = $mailSend;
591
-		return $this;
592
-	}
593
-
594
-	/**
595
-	 * @inheritdoc
596
-	 */
597
-	public function getMailSend() {
598
-		return $this->mailSend;
599
-	}
600
-
601
-	/**
602
-	 * @inheritdoc
603
-	 */
604
-	public function setNodeCacheEntry(ICacheEntry $entry) {
605
-		$this->nodeCacheEntry = $entry;
606
-	}
607
-
608
-	/**
609
-	 * @inheritdoc
610
-	 */
611
-	public function getNodeCacheEntry() {
612
-		return $this->nodeCacheEntry;
613
-	}
614
-
615
-	public function setHideDownload(bool $hide): IShare {
616
-		$this->hideDownload = $hide;
617
-		return $this;
618
-	}
619
-
620
-	public function getHideDownload(): bool {
621
-		return $this->hideDownload;
622
-	}
44
+    /** @var string */
45
+    private $id;
46
+    /** @var string */
47
+    private $providerId;
48
+    /** @var Node */
49
+    private $node;
50
+    /** @var int */
51
+    private $fileId;
52
+    /** @var string */
53
+    private $nodeType;
54
+    /** @var int */
55
+    private $shareType;
56
+    /** @var string */
57
+    private $sharedWith;
58
+    /** @var string */
59
+    private $sharedWithDisplayName;
60
+    /** @var string */
61
+    private $sharedWithAvatar;
62
+    /** @var string */
63
+    private $sharedBy;
64
+    /** @var string */
65
+    private $shareOwner;
66
+    /** @var int */
67
+    private $permissions;
68
+    /** @var IAttributes */
69
+    private $attributes;
70
+    /** @var int */
71
+    private $status;
72
+    /** @var string */
73
+    private $note = '';
74
+    /** @var \DateTime */
75
+    private $expireDate;
76
+    /** @var string */
77
+    private $password;
78
+    private ?\DateTimeInterface $passwordExpirationTime = null;
79
+    /** @var bool */
80
+    private $sendPasswordByTalk = false;
81
+    /** @var string */
82
+    private $token;
83
+    /** @var int */
84
+    private $parent;
85
+    /** @var string */
86
+    private $target;
87
+    /** @var \DateTime */
88
+    private $shareTime;
89
+    /** @var bool */
90
+    private $mailSend;
91
+    /** @var string */
92
+    private $label = '';
93
+
94
+    /** @var IRootFolder */
95
+    private $rootFolder;
96
+
97
+    /** @var IUserManager */
98
+    private $userManager;
99
+
100
+    /** @var ICacheEntry|null */
101
+    private $nodeCacheEntry;
102
+
103
+    /** @var bool */
104
+    private $hideDownload = false;
105
+
106
+    public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
107
+        $this->rootFolder = $rootFolder;
108
+        $this->userManager = $userManager;
109
+    }
110
+
111
+    /**
112
+     * @inheritdoc
113
+     */
114
+    public function setId($id) {
115
+        if (is_int($id)) {
116
+            $id = (string)$id;
117
+        }
118
+
119
+        if (!is_string($id)) {
120
+            throw new \InvalidArgumentException('String expected.');
121
+        }
122
+
123
+        if ($this->id !== null) {
124
+            throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
125
+        }
126
+
127
+        $this->id = trim($id);
128
+        return $this;
129
+    }
130
+
131
+    /**
132
+     * @inheritdoc
133
+     */
134
+    public function getId() {
135
+        return $this->id;
136
+    }
137
+
138
+    /**
139
+     * @inheritdoc
140
+     */
141
+    public function getFullId() {
142
+        if ($this->providerId === null || $this->id === null) {
143
+            throw new \UnexpectedValueException;
144
+        }
145
+        return $this->providerId . ':' . $this->id;
146
+    }
147
+
148
+    /**
149
+     * @inheritdoc
150
+     */
151
+    public function setProviderId($id) {
152
+        if (!is_string($id)) {
153
+            throw new \InvalidArgumentException('String expected.');
154
+        }
155
+
156
+        if ($this->providerId !== null) {
157
+            throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
158
+        }
159
+
160
+        $this->providerId = trim($id);
161
+        return $this;
162
+    }
163
+
164
+    /**
165
+     * @inheritdoc
166
+     */
167
+    public function setNode(Node $node) {
168
+        $this->fileId = null;
169
+        $this->nodeType = null;
170
+        $this->node = $node;
171
+        return $this;
172
+    }
173
+
174
+    /**
175
+     * @inheritdoc
176
+     */
177
+    public function getNode() {
178
+        if ($this->node === null) {
179
+            if ($this->shareOwner === null || $this->fileId === null) {
180
+                throw new NotFoundException();
181
+            }
182
+
183
+            // for federated shares the owner can be a remote user, in this
184
+            // case we use the initiator
185
+            if ($this->userManager->userExists($this->shareOwner)) {
186
+                $userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
187
+            } else {
188
+                $userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
189
+            }
190
+
191
+            $nodes = $userFolder->getById($this->fileId);
192
+            if (empty($nodes)) {
193
+                throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
194
+            }
195
+
196
+            $this->node = $nodes[0];
197
+        }
198
+
199
+        return $this->node;
200
+    }
201
+
202
+    /**
203
+     * @inheritdoc
204
+     */
205
+    public function setNodeId($fileId) {
206
+        $this->node = null;
207
+        $this->fileId = $fileId;
208
+        return $this;
209
+    }
210
+
211
+    /**
212
+     * @inheritdoc
213
+     */
214
+    public function getNodeId() {
215
+        if ($this->fileId === null) {
216
+            $this->fileId = $this->getNode()->getId();
217
+        }
218
+
219
+        return $this->fileId;
220
+    }
221
+
222
+    /**
223
+     * @inheritdoc
224
+     */
225
+    public function setNodeType($type) {
226
+        if ($type !== 'file' && $type !== 'folder') {
227
+            throw new \InvalidArgumentException();
228
+        }
229
+
230
+        $this->nodeType = $type;
231
+        return $this;
232
+    }
233
+
234
+    /**
235
+     * @inheritdoc
236
+     */
237
+    public function getNodeType() {
238
+        if ($this->nodeType === null) {
239
+            if ($this->getNodeCacheEntry()) {
240
+                $info = $this->getNodeCacheEntry();
241
+                $this->nodeType = $info->getMimeType() === FileInfo::MIMETYPE_FOLDER ? 'folder' : 'file';
242
+            } else {
243
+                $node = $this->getNode();
244
+                $this->nodeType = $node instanceof File ? 'file' : 'folder';
245
+            }
246
+        }
247
+
248
+        return $this->nodeType;
249
+    }
250
+
251
+    /**
252
+     * @inheritdoc
253
+     */
254
+    public function setShareType($shareType) {
255
+        $this->shareType = $shareType;
256
+        return $this;
257
+    }
258
+
259
+    /**
260
+     * @inheritdoc
261
+     */
262
+    public function getShareType() {
263
+        return $this->shareType;
264
+    }
265
+
266
+    /**
267
+     * @inheritdoc
268
+     */
269
+    public function setSharedWith($sharedWith) {
270
+        if (!is_string($sharedWith)) {
271
+            throw new \InvalidArgumentException();
272
+        }
273
+        $this->sharedWith = $sharedWith;
274
+        return $this;
275
+    }
276
+
277
+    /**
278
+     * @inheritdoc
279
+     */
280
+    public function getSharedWith() {
281
+        return $this->sharedWith;
282
+    }
283
+
284
+    /**
285
+     * @inheritdoc
286
+     */
287
+    public function setSharedWithDisplayName($displayName) {
288
+        if (!is_string($displayName)) {
289
+            throw new \InvalidArgumentException();
290
+        }
291
+        $this->sharedWithDisplayName = $displayName;
292
+        return $this;
293
+    }
294
+
295
+    /**
296
+     * @inheritdoc
297
+     */
298
+    public function getSharedWithDisplayName() {
299
+        return $this->sharedWithDisplayName;
300
+    }
301
+
302
+    /**
303
+     * @inheritdoc
304
+     */
305
+    public function setSharedWithAvatar($src) {
306
+        if (!is_string($src)) {
307
+            throw new \InvalidArgumentException();
308
+        }
309
+        $this->sharedWithAvatar = $src;
310
+        return $this;
311
+    }
312
+
313
+    /**
314
+     * @inheritdoc
315
+     */
316
+    public function getSharedWithAvatar() {
317
+        return $this->sharedWithAvatar;
318
+    }
319
+
320
+    /**
321
+     * @inheritdoc
322
+     */
323
+    public function setPermissions($permissions) {
324
+        //TODO checks
325
+
326
+        $this->permissions = $permissions;
327
+        return $this;
328
+    }
329
+
330
+    /**
331
+     * @inheritdoc
332
+     */
333
+    public function getPermissions() {
334
+        return $this->permissions;
335
+    }
336
+
337
+    /**
338
+     * @inheritdoc
339
+     */
340
+    public function newAttributes(): IAttributes {
341
+        return new ShareAttributes();
342
+    }
343
+
344
+    /**
345
+     * @inheritdoc
346
+     */
347
+    public function setAttributes(?IAttributes $attributes) {
348
+        $this->attributes = $attributes;
349
+        return $this;
350
+    }
351
+
352
+    /**
353
+     * @inheritdoc
354
+     */
355
+    public function getAttributes(): ?IAttributes {
356
+        return $this->attributes;
357
+    }
358
+
359
+    /**
360
+     * @inheritdoc
361
+     */
362
+    public function setStatus(int $status): IShare {
363
+        $this->status = $status;
364
+        return $this;
365
+    }
366
+
367
+    /**
368
+     * @inheritdoc
369
+     */
370
+    public function getStatus(): int {
371
+        return $this->status;
372
+    }
373
+
374
+    /**
375
+     * @inheritdoc
376
+     */
377
+    public function setNote($note) {
378
+        $this->note = $note;
379
+        return $this;
380
+    }
381
+
382
+    /**
383
+     * @inheritdoc
384
+     */
385
+    public function getNote() {
386
+        if (is_string($this->note)) {
387
+            return $this->note;
388
+        }
389
+        return '';
390
+    }
391
+
392
+    /**
393
+     * @inheritdoc
394
+     */
395
+    public function setLabel($label) {
396
+        $this->label = $label;
397
+        return $this;
398
+    }
399
+
400
+    /**
401
+     * @inheritdoc
402
+     */
403
+    public function getLabel() {
404
+        return $this->label;
405
+    }
406
+
407
+    /**
408
+     * @inheritdoc
409
+     */
410
+    public function setExpirationDate($expireDate) {
411
+        //TODO checks
412
+
413
+        $this->expireDate = $expireDate;
414
+        return $this;
415
+    }
416
+
417
+    /**
418
+     * @inheritdoc
419
+     */
420
+    public function getExpirationDate() {
421
+        return $this->expireDate;
422
+    }
423
+
424
+    /**
425
+     * @inheritdoc
426
+     */
427
+    public function isExpired() {
428
+        return $this->getExpirationDate() !== null &&
429
+            $this->getExpirationDate() <= new \DateTime();
430
+    }
431
+
432
+    /**
433
+     * @inheritdoc
434
+     */
435
+    public function setSharedBy($sharedBy) {
436
+        if (!is_string($sharedBy)) {
437
+            throw new \InvalidArgumentException();
438
+        }
439
+        //TODO checks
440
+        $this->sharedBy = $sharedBy;
441
+
442
+        return $this;
443
+    }
444
+
445
+    /**
446
+     * @inheritdoc
447
+     */
448
+    public function getSharedBy() {
449
+        //TODO check if set
450
+        return $this->sharedBy;
451
+    }
452
+
453
+    /**
454
+     * @inheritdoc
455
+     */
456
+    public function setShareOwner($shareOwner) {
457
+        if (!is_string($shareOwner)) {
458
+            throw new \InvalidArgumentException();
459
+        }
460
+        //TODO checks
461
+
462
+        $this->shareOwner = $shareOwner;
463
+        return $this;
464
+    }
465
+
466
+    /**
467
+     * @inheritdoc
468
+     */
469
+    public function getShareOwner() {
470
+        //TODO check if set
471
+        return $this->shareOwner;
472
+    }
473
+
474
+    /**
475
+     * @inheritdoc
476
+     */
477
+    public function setPassword($password) {
478
+        $this->password = $password;
479
+        return $this;
480
+    }
481
+
482
+    /**
483
+     * @inheritdoc
484
+     */
485
+    public function getPassword() {
486
+        return $this->password;
487
+    }
488
+
489
+    /**
490
+     * @inheritdoc
491
+     */
492
+    public function setPasswordExpirationTime(?\DateTimeInterface $passwordExpirationTime = null): IShare {
493
+        $this->passwordExpirationTime = $passwordExpirationTime;
494
+        return $this;
495
+    }
496
+
497
+    /**
498
+     * @inheritdoc
499
+     */
500
+    public function getPasswordExpirationTime(): ?\DateTimeInterface {
501
+        return $this->passwordExpirationTime;
502
+    }
503
+
504
+    /**
505
+     * @inheritdoc
506
+     */
507
+    public function setSendPasswordByTalk(bool $sendPasswordByTalk) {
508
+        $this->sendPasswordByTalk = $sendPasswordByTalk;
509
+        return $this;
510
+    }
511
+
512
+    /**
513
+     * @inheritdoc
514
+     */
515
+    public function getSendPasswordByTalk(): bool {
516
+        return $this->sendPasswordByTalk;
517
+    }
518
+
519
+    /**
520
+     * @inheritdoc
521
+     */
522
+    public function setToken($token) {
523
+        $this->token = $token;
524
+        return $this;
525
+    }
526
+
527
+    /**
528
+     * @inheritdoc
529
+     */
530
+    public function getToken() {
531
+        return $this->token;
532
+    }
533
+
534
+    /**
535
+     * Set the parent of this share
536
+     *
537
+     * @param int parent
538
+     * @return IShare
539
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
540
+     */
541
+    public function setParent($parent) {
542
+        $this->parent = $parent;
543
+        return $this;
544
+    }
545
+
546
+    /**
547
+     * Get the parent of this share.
548
+     *
549
+     * @return int
550
+     * @deprecated The new shares do not have parents. This is just here for legacy reasons.
551
+     */
552
+    public function getParent() {
553
+        return $this->parent;
554
+    }
555
+
556
+    /**
557
+     * @inheritdoc
558
+     */
559
+    public function setTarget($target) {
560
+        $this->target = $target;
561
+        return $this;
562
+    }
563
+
564
+    /**
565
+     * @inheritdoc
566
+     */
567
+    public function getTarget() {
568
+        return $this->target;
569
+    }
570
+
571
+    /**
572
+     * @inheritdoc
573
+     */
574
+    public function setShareTime(\DateTime $shareTime) {
575
+        $this->shareTime = $shareTime;
576
+        return $this;
577
+    }
578
+
579
+    /**
580
+     * @inheritdoc
581
+     */
582
+    public function getShareTime() {
583
+        return $this->shareTime;
584
+    }
585
+
586
+    /**
587
+     * @inheritdoc
588
+     */
589
+    public function setMailSend($mailSend) {
590
+        $this->mailSend = $mailSend;
591
+        return $this;
592
+    }
593
+
594
+    /**
595
+     * @inheritdoc
596
+     */
597
+    public function getMailSend() {
598
+        return $this->mailSend;
599
+    }
600
+
601
+    /**
602
+     * @inheritdoc
603
+     */
604
+    public function setNodeCacheEntry(ICacheEntry $entry) {
605
+        $this->nodeCacheEntry = $entry;
606
+    }
607
+
608
+    /**
609
+     * @inheritdoc
610
+     */
611
+    public function getNodeCacheEntry() {
612
+        return $this->nodeCacheEntry;
613
+    }
614
+
615
+    public function setHideDownload(bool $hide): IShare {
616
+        $this->hideDownload = $hide;
617
+        return $this;
618
+    }
619
+
620
+    public function getHideDownload(): bool {
621
+        return $this->hideDownload;
622
+    }
623 623
 }
Please login to merge, or discard this patch.
lib/private/CapabilitiesManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 					$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
61 61
 				}
62 62
 			} else {
63
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
63
+				throw new \InvalidArgumentException('The given Capability ('.get_class($c).') does not implement the ICapability interface');
64 64
 			}
65 65
 		}
66 66
 
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -35,61 +35,61 @@
 block discarded – undo
35 35
 use Psr\Log\LoggerInterface;
36 36
 
37 37
 class CapabilitiesManager {
38
-	/** @var \Closure[] */
39
-	private $capabilities = [];
38
+    /** @var \Closure[] */
39
+    private $capabilities = [];
40 40
 
41
-	/** @var LoggerInterface */
42
-	private $logger;
41
+    /** @var LoggerInterface */
42
+    private $logger;
43 43
 
44
-	public function __construct(LoggerInterface $logger) {
45
-		$this->logger = $logger;
46
-	}
44
+    public function __construct(LoggerInterface $logger) {
45
+        $this->logger = $logger;
46
+    }
47 47
 
48
-	/**
49
-	 * Get an array of al the capabilities that are registered at this manager
50
-	 *
51
-	 * @param bool $public get public capabilities only
52
-	 * @throws \InvalidArgumentException
53
-	 * @return array
54
-	 */
55
-	public function getCapabilities(bool $public = false, bool $initialState = false) : array {
56
-		$capabilities = [];
57
-		foreach ($this->capabilities as $capability) {
58
-			try {
59
-				$c = $capability();
60
-			} catch (QueryException $e) {
61
-				$this->logger->error('CapabilitiesManager', [
62
-					'exception' => $e,
63
-				]);
64
-				continue;
65
-			}
48
+    /**
49
+     * Get an array of al the capabilities that are registered at this manager
50
+     *
51
+     * @param bool $public get public capabilities only
52
+     * @throws \InvalidArgumentException
53
+     * @return array
54
+     */
55
+    public function getCapabilities(bool $public = false, bool $initialState = false) : array {
56
+        $capabilities = [];
57
+        foreach ($this->capabilities as $capability) {
58
+            try {
59
+                $c = $capability();
60
+            } catch (QueryException $e) {
61
+                $this->logger->error('CapabilitiesManager', [
62
+                    'exception' => $e,
63
+                ]);
64
+                continue;
65
+            }
66 66
 
67
-			if ($c instanceof ICapability) {
68
-				if (!$public || $c instanceof IPublicCapability) {
69
-					if ($initialState && ($c instanceof IInitialStateExcludedCapability)) {
70
-						// Remove less important capabilities information that are expensive to query
71
-						// that we would otherwise inject to every page load
72
-						continue;
73
-					}
74
-					$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
75
-				}
76
-			} else {
77
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
78
-			}
79
-		}
67
+            if ($c instanceof ICapability) {
68
+                if (!$public || $c instanceof IPublicCapability) {
69
+                    if ($initialState && ($c instanceof IInitialStateExcludedCapability)) {
70
+                        // Remove less important capabilities information that are expensive to query
71
+                        // that we would otherwise inject to every page load
72
+                        continue;
73
+                    }
74
+                    $capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
75
+                }
76
+            } else {
77
+                throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
78
+            }
79
+        }
80 80
 
81
-		return $capabilities;
82
-	}
81
+        return $capabilities;
82
+    }
83 83
 
84
-	/**
85
-	 * In order to improve lazy loading a closure can be registered which will be called in case
86
-	 * capabilities are actually requested
87
-	 *
88
-	 * $callable has to return an instance of OCP\Capabilities\ICapability
89
-	 *
90
-	 * @param \Closure $callable
91
-	 */
92
-	public function registerCapability(\Closure $callable) {
93
-		$this->capabilities[] = $callable;
94
-	}
84
+    /**
85
+     * In order to improve lazy loading a closure can be registered which will be called in case
86
+     * capabilities are actually requested
87
+     *
88
+     * $callable has to return an instance of OCP\Capabilities\ICapability
89
+     *
90
+     * @param \Closure $callable
91
+     */
92
+    public function registerCapability(\Closure $callable) {
93
+        $this->capabilities[] = $callable;
94
+    }
95 95
 }
Please login to merge, or discard this patch.
lib/private/OCS/Result.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
 	 * @return $this
136 136
 	 */
137 137
 	public function addHeader($name, $value) {
138
-		$name = trim($name);  // always remove leading and trailing whitespace
138
+		$name = trim($name); // always remove leading and trailing whitespace
139 139
 		// to be able to reliably check for security
140 140
 		// headers
141 141
 
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -31,127 +31,127 @@
 block discarded – undo
31 31
 namespace OC\OCS;
32 32
 
33 33
 class Result {
34
-	/** @var array  */
35
-	protected $data;
36
-
37
-	/** @var null|string */
38
-	protected $message;
39
-
40
-	/** @var int */
41
-	protected $statusCode;
42
-
43
-	/** @var integer */
44
-	protected $items;
45
-
46
-	/** @var integer */
47
-	protected $perPage;
48
-
49
-	/** @var array */
50
-	private $headers = [];
51
-
52
-	/**
53
-	 * create the OCS_Result object
54
-	 * @param mixed $data the data to return
55
-	 * @param int $code
56
-	 * @param null|string $message
57
-	 * @param array $headers
58
-	 */
59
-	public function __construct($data = null, $code = 100, $message = null, $headers = []) {
60
-		if ($data === null) {
61
-			$this->data = [];
62
-		} elseif (!is_array($data)) {
63
-			$this->data = [$this->data];
64
-		} else {
65
-			$this->data = $data;
66
-		}
67
-		$this->statusCode = $code;
68
-		$this->message = $message;
69
-		$this->headers = $headers;
70
-	}
71
-
72
-	/**
73
-	 * optionally set the total number of items available
74
-	 * @param int $items
75
-	 */
76
-	public function setTotalItems($items) {
77
-		$this->items = $items;
78
-	}
79
-
80
-	/**
81
-	 * optionally set the the number of items per page
82
-	 * @param int $items
83
-	 */
84
-	public function setItemsPerPage($items) {
85
-		$this->perPage = $items;
86
-	}
87
-
88
-	/**
89
-	 * get the status code
90
-	 * @return int
91
-	 */
92
-	public function getStatusCode() {
93
-		return $this->statusCode;
94
-	}
95
-
96
-	/**
97
-	 * get the meta data for the result
98
-	 * @return array
99
-	 */
100
-	public function getMeta() {
101
-		$meta = [];
102
-		$meta['status'] = $this->succeeded() ? 'ok' : 'failure';
103
-		$meta['statuscode'] = $this->statusCode;
104
-		$meta['message'] = $this->message;
105
-		if ($this->items !== null) {
106
-			$meta['totalitems'] = $this->items;
107
-		}
108
-		if ($this->perPage !== null) {
109
-			$meta['itemsperpage'] = $this->perPage;
110
-		}
111
-		return $meta;
112
-	}
113
-
114
-	/**
115
-	 * get the result data
116
-	 * @return array
117
-	 */
118
-	public function getData() {
119
-		return $this->data;
120
-	}
121
-
122
-	/**
123
-	 * return bool Whether the method succeeded
124
-	 * @return bool
125
-	 */
126
-	public function succeeded() {
127
-		return ($this->statusCode == 100);
128
-	}
129
-
130
-	/**
131
-	 * Adds a new header to the response
132
-	 * @param string $name The name of the HTTP header
133
-	 * @param string $value The value, null will delete it
134
-	 * @return $this
135
-	 */
136
-	public function addHeader($name, $value) {
137
-		$name = trim($name);  // always remove leading and trailing whitespace
138
-		// to be able to reliably check for security
139
-		// headers
140
-
141
-		if (is_null($value)) {
142
-			unset($this->headers[$name]);
143
-		} else {
144
-			$this->headers[$name] = $value;
145
-		}
146
-
147
-		return $this;
148
-	}
149
-
150
-	/**
151
-	 * Returns the set headers
152
-	 * @return array the headers
153
-	 */
154
-	public function getHeaders() {
155
-		return $this->headers;
156
-	}
34
+    /** @var array  */
35
+    protected $data;
36
+
37
+    /** @var null|string */
38
+    protected $message;
39
+
40
+    /** @var int */
41
+    protected $statusCode;
42
+
43
+    /** @var integer */
44
+    protected $items;
45
+
46
+    /** @var integer */
47
+    protected $perPage;
48
+
49
+    /** @var array */
50
+    private $headers = [];
51
+
52
+    /**
53
+     * create the OCS_Result object
54
+     * @param mixed $data the data to return
55
+     * @param int $code
56
+     * @param null|string $message
57
+     * @param array $headers
58
+     */
59
+    public function __construct($data = null, $code = 100, $message = null, $headers = []) {
60
+        if ($data === null) {
61
+            $this->data = [];
62
+        } elseif (!is_array($data)) {
63
+            $this->data = [$this->data];
64
+        } else {
65
+            $this->data = $data;
66
+        }
67
+        $this->statusCode = $code;
68
+        $this->message = $message;
69
+        $this->headers = $headers;
70
+    }
71
+
72
+    /**
73
+     * optionally set the total number of items available
74
+     * @param int $items
75
+     */
76
+    public function setTotalItems($items) {
77
+        $this->items = $items;
78
+    }
79
+
80
+    /**
81
+     * optionally set the the number of items per page
82
+     * @param int $items
83
+     */
84
+    public function setItemsPerPage($items) {
85
+        $this->perPage = $items;
86
+    }
87
+
88
+    /**
89
+     * get the status code
90
+     * @return int
91
+     */
92
+    public function getStatusCode() {
93
+        return $this->statusCode;
94
+    }
95
+
96
+    /**
97
+     * get the meta data for the result
98
+     * @return array
99
+     */
100
+    public function getMeta() {
101
+        $meta = [];
102
+        $meta['status'] = $this->succeeded() ? 'ok' : 'failure';
103
+        $meta['statuscode'] = $this->statusCode;
104
+        $meta['message'] = $this->message;
105
+        if ($this->items !== null) {
106
+            $meta['totalitems'] = $this->items;
107
+        }
108
+        if ($this->perPage !== null) {
109
+            $meta['itemsperpage'] = $this->perPage;
110
+        }
111
+        return $meta;
112
+    }
113
+
114
+    /**
115
+     * get the result data
116
+     * @return array
117
+     */
118
+    public function getData() {
119
+        return $this->data;
120
+    }
121
+
122
+    /**
123
+     * return bool Whether the method succeeded
124
+     * @return bool
125
+     */
126
+    public function succeeded() {
127
+        return ($this->statusCode == 100);
128
+    }
129
+
130
+    /**
131
+     * Adds a new header to the response
132
+     * @param string $name The name of the HTTP header
133
+     * @param string $value The value, null will delete it
134
+     * @return $this
135
+     */
136
+    public function addHeader($name, $value) {
137
+        $name = trim($name);  // always remove leading and trailing whitespace
138
+        // to be able to reliably check for security
139
+        // headers
140
+
141
+        if (is_null($value)) {
142
+            unset($this->headers[$name]);
143
+        } else {
144
+            $this->headers[$name] = $value;
145
+        }
146
+
147
+        return $this;
148
+    }
149
+
150
+    /**
151
+     * Returns the set headers
152
+     * @return array the headers
153
+     */
154
+    public function getHeaders() {
155
+        return $this->headers;
156
+    }
157 157
 }
Please login to merge, or discard this patch.
lib/private/Files/Storage/CommonTest.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -33,53 +33,53 @@
 block discarded – undo
33 33
 namespace OC\Files\Storage;
34 34
 
35 35
 class CommonTest extends \OC\Files\Storage\Common {
36
-	/**
37
-	 * underlying local storage used for missing functions
38
-	 * @var \OC\Files\Storage\Local
39
-	 */
40
-	private $storage;
36
+    /**
37
+     * underlying local storage used for missing functions
38
+     * @var \OC\Files\Storage\Local
39
+     */
40
+    private $storage;
41 41
 
42
-	public function __construct($params) {
43
-		$this->storage = new \OC\Files\Storage\Local($params);
44
-	}
42
+    public function __construct($params) {
43
+        $this->storage = new \OC\Files\Storage\Local($params);
44
+    }
45 45
 
46
-	public function getId() {
47
-		return 'test::'.$this->storage->getId();
48
-	}
49
-	public function mkdir($path) {
50
-		return $this->storage->mkdir($path);
51
-	}
52
-	public function rmdir($path) {
53
-		return $this->storage->rmdir($path);
54
-	}
55
-	public function opendir($path) {
56
-		return $this->storage->opendir($path);
57
-	}
58
-	public function stat($path) {
59
-		return $this->storage->stat($path);
60
-	}
61
-	public function filetype($path) {
62
-		return @$this->storage->filetype($path);
63
-	}
64
-	public function isReadable($path) {
65
-		return $this->storage->isReadable($path);
66
-	}
67
-	public function isUpdatable($path) {
68
-		return $this->storage->isUpdatable($path);
69
-	}
70
-	public function file_exists($path) {
71
-		return $this->storage->file_exists($path);
72
-	}
73
-	public function unlink($path) {
74
-		return $this->storage->unlink($path);
75
-	}
76
-	public function fopen($path, $mode) {
77
-		return $this->storage->fopen($path, $mode);
78
-	}
79
-	public function free_space($path) {
80
-		return $this->storage->free_space($path);
81
-	}
82
-	public function touch($path, $mtime = null) {
83
-		return $this->storage->touch($path, $mtime);
84
-	}
46
+    public function getId() {
47
+        return 'test::'.$this->storage->getId();
48
+    }
49
+    public function mkdir($path) {
50
+        return $this->storage->mkdir($path);
51
+    }
52
+    public function rmdir($path) {
53
+        return $this->storage->rmdir($path);
54
+    }
55
+    public function opendir($path) {
56
+        return $this->storage->opendir($path);
57
+    }
58
+    public function stat($path) {
59
+        return $this->storage->stat($path);
60
+    }
61
+    public function filetype($path) {
62
+        return @$this->storage->filetype($path);
63
+    }
64
+    public function isReadable($path) {
65
+        return $this->storage->isReadable($path);
66
+    }
67
+    public function isUpdatable($path) {
68
+        return $this->storage->isUpdatable($path);
69
+    }
70
+    public function file_exists($path) {
71
+        return $this->storage->file_exists($path);
72
+    }
73
+    public function unlink($path) {
74
+        return $this->storage->unlink($path);
75
+    }
76
+    public function fopen($path, $mode) {
77
+        return $this->storage->fopen($path, $mode);
78
+    }
79
+    public function free_space($path) {
80
+        return $this->storage->free_space($path);
81
+    }
82
+    public function touch($path, $mtime = null) {
83
+        return $this->storage->touch($path, $mtime);
84
+    }
85 85
 }
Please login to merge, or discard this patch.
lib/private/Files/Storage/Temporary.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@
 block discarded – undo
29 29
  * local storage backend in temporary folder for testing purpose
30 30
  */
31 31
 class Temporary extends Local {
32
-	public function __construct($arguments = null) {
33
-		parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]);
34
-	}
32
+    public function __construct($arguments = null) {
33
+        parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]);
34
+    }
35 35
 
36
-	public function cleanUp() {
37
-		\OC_Helper::rmdirr($this->datadir);
38
-	}
36
+    public function cleanUp() {
37
+        \OC_Helper::rmdirr($this->datadir);
38
+    }
39 39
 
40
-	public function __destruct() {
41
-		parent::__destruct();
42
-		$this->cleanUp();
43
-	}
40
+    public function __destruct() {
41
+        parent::__destruct();
42
+        $this->cleanUp();
43
+    }
44 44
 
45
-	public function getDataDir() {
46
-		return $this->datadir;
47
-	}
45
+    public function getDataDir() {
46
+        return $this->datadir;
47
+    }
48 48
 }
Please login to merge, or discard this patch.