Passed
Push — master ( 8355f9...6d2471 )
by Blizzz
12:04 queued 10s
created
files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
  * Authentication mechanism or backend has insufficient data
30 30
  */
31 31
 class InsufficientDataForMeaningfulAnswerException extends StorageNotAvailableException {
32
-	/**
33
-	 * StorageNotAvailableException constructor.
34
-	 *
35
-	 * @param string $message
36
-	 * @param int $code
37
-	 * @param \Exception|null $previous
38
-	 * @since 6.0.0
39
-	 */
40
-	public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
-		parent::__construct($message, $code, $previous);
42
-	}
32
+    /**
33
+     * StorageNotAvailableException constructor.
34
+     *
35
+     * @param string $message
36
+     * @param int $code
37
+     * @param \Exception|null $previous
38
+     * @since 6.0.0
39
+     */
40
+    public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
+        parent::__construct($message, $code, $previous);
42
+    }
43 43
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/IdentifierTrait.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -28,76 +28,76 @@
 block discarded – undo
28 28
  */
29 29
 trait IdentifierTrait {
30 30
 
31
-	/** @var string */
32
-	protected $identifier;
31
+    /** @var string */
32
+    protected $identifier;
33 33
 
34
-	/** @var string[] */
35
-	protected $identifierAliases = [];
34
+    /** @var string[] */
35
+    protected $identifierAliases = [];
36 36
 
37
-	/** @var IdentifierTrait */
38
-	protected $deprecateTo = null;
37
+    /** @var IdentifierTrait */
38
+    protected $deprecateTo = null;
39 39
 
40
-	/**
41
-	 * @return string
42
-	 */
43
-	public function getIdentifier() {
44
-		return $this->identifier;
45
-	}
40
+    /**
41
+     * @return string
42
+     */
43
+    public function getIdentifier() {
44
+        return $this->identifier;
45
+    }
46 46
 
47
-	/**
48
-	 * @param string $identifier
49
-	 * @return $this
50
-	 */
51
-	public function setIdentifier($identifier) {
52
-		$this->identifier = $identifier;
53
-		$this->identifierAliases[] = $identifier;
54
-		return $this;
55
-	}
47
+    /**
48
+     * @param string $identifier
49
+     * @return $this
50
+     */
51
+    public function setIdentifier($identifier) {
52
+        $this->identifier = $identifier;
53
+        $this->identifierAliases[] = $identifier;
54
+        return $this;
55
+    }
56 56
 
57
-	/**
58
-	 * @return string[]
59
-	 */
60
-	public function getIdentifierAliases() {
61
-		return $this->identifierAliases;
62
-	}
57
+    /**
58
+     * @return string[]
59
+     */
60
+    public function getIdentifierAliases() {
61
+        return $this->identifierAliases;
62
+    }
63 63
 
64
-	/**
65
-	 * @param string $alias
66
-	 * @return $this
67
-	 */
68
-	public function addIdentifierAlias($alias) {
69
-		$this->identifierAliases[] = $alias;
70
-		return $this;
71
-	}
64
+    /**
65
+     * @param string $alias
66
+     * @return $this
67
+     */
68
+    public function addIdentifierAlias($alias) {
69
+        $this->identifierAliases[] = $alias;
70
+        return $this;
71
+    }
72 72
 
73
-	/**
74
-	 * @return object|null
75
-	 */
76
-	public function getDeprecateTo() {
77
-		return $this->deprecateTo;
78
-	}
73
+    /**
74
+     * @return object|null
75
+     */
76
+    public function getDeprecateTo() {
77
+        return $this->deprecateTo;
78
+    }
79 79
 
80
-	/**
81
-	 * @param object $destinationObject
82
-	 * @return self
83
-	 */
84
-	public function deprecateTo($destinationObject) {
85
-		$this->deprecateTo = $destinationObject;
86
-		return $this;
87
-	}
80
+    /**
81
+     * @param object $destinationObject
82
+     * @return self
83
+     */
84
+    public function deprecateTo($destinationObject) {
85
+        $this->deprecateTo = $destinationObject;
86
+        return $this;
87
+    }
88 88
 
89
-	/**
90
-	 * @return array
91
-	 */
92
-	public function jsonSerializeIdentifier() {
93
-		$data = [
94
-			'identifier' => $this->identifier,
95
-			'identifierAliases' => $this->identifierAliases,
96
-		];
97
-		if ($this->deprecateTo) {
98
-			$data['deprecateTo'] = $this->deprecateTo->getIdentifier();
99
-		}
100
-		return $data;
101
-	}
89
+    /**
90
+     * @return array
91
+     */
92
+    public function jsonSerializeIdentifier() {
93
+        $data = [
94
+            'identifier' => $this->identifier,
95
+            'identifierAliases' => $this->identifierAliases,
96
+        ];
97
+        if ($this->deprecateTo) {
98
+            $data['deprecateTo'] = $this->deprecateTo->getIdentifier();
99
+        }
100
+        return $data;
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Create.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -128,32 +128,32 @@  discard block
 block discarded – undo
128 128
 		$authBackend = $this->backendService->getAuthMechanism($authIdentifier);
129 129
 
130 130
 		if (!Filesystem::isValidPath($mountPoint)) {
131
-			$output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>');
131
+			$output->writeln('<error>Invalid mountpoint "'.$mountPoint.'"</error>');
132 132
 			return 1;
133 133
 		}
134 134
 		if (is_null($storageBackend)) {
135
-			$output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
135
+			$output->writeln('<error>Storage backend with identifier "'.$storageIdentifier.'" not found (see `occ files_external:backends` for possible values)</error>');
136 136
 			return 404;
137 137
 		}
138 138
 		if (is_null($authBackend)) {
139
-			$output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
139
+			$output->writeln('<error>Authentication backend with identifier "'.$authIdentifier.'" not found (see `occ files_external:backends` for possible values)</error>');
140 140
 			return 404;
141 141
 		}
142 142
 		$supportedSchemes = array_keys($storageBackend->getAuthSchemes());
143 143
 		if (!in_array($authBackend->getScheme(), $supportedSchemes)) {
144
-			$output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>');
144
+			$output->writeln('<error>Authentication backend "'.$authIdentifier.'" not valid for storage backend "'.$storageIdentifier.'" (see `occ files_external:backends storage '.$storageIdentifier.'` for possible values)</error>');
145 145
 			return 1;
146 146
 		}
147 147
 
148 148
 		$config = [];
149 149
 		foreach ($configInput as $configOption) {
150 150
 			if (!strpos($configOption, '=')) {
151
-				$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
151
+				$output->writeln('<error>Invalid mount configuration option "'.$configOption.'"</error>');
152 152
 				return 1;
153 153
 			}
154 154
 			list($key, $value) = explode('=', $configOption, 2);
155 155
 			if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) {
156
-				$output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>');
156
+				$output->writeln('<error>Unknown configuration for backends "'.$key.'"</error>');
157 157
 				return 1;
158 158
 			}
159 159
 			$config[$key] = $value;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 		if ($user) {
169 169
 			if (!$this->userManager->userExists($user)) {
170
-				$output->writeln('<error>User "' . $user . '" not found</error>');
170
+				$output->writeln('<error>User "'.$user.'" not found</error>');
171 171
 				return 1;
172 172
 			}
173 173
 			$mount->setApplicableUsers([$user]);
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 		} else {
179 179
 			$this->getStorageService($user)->addStorage($mount);
180 180
 			if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
181
-				$output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>');
181
+				$output->writeln('<info>Storage created with id '.$mount->getId().'</info>');
182 182
 			} else {
183
-				$output->writeln((string)$mount->getId());
183
+				$output->writeln((string) $mount->getId());
184 184
 			}
185 185
 		}
186 186
 		return 0;
Please login to merge, or discard this patch.
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -44,182 +44,182 @@
 block discarded – undo
44 44
 use Symfony\Component\Console\Output\OutputInterface;
45 45
 
46 46
 class Create extends Base {
47
-	/**
48
-	 * @var GlobalStoragesService
49
-	 */
50
-	private $globalService;
51
-
52
-	/**
53
-	 * @var UserStoragesService
54
-	 */
55
-	private $userService;
56
-
57
-	/**
58
-	 * @var IUserManager
59
-	 */
60
-	private $userManager;
61
-
62
-	/** @var BackendService */
63
-	private $backendService;
64
-
65
-	/** @var IUserSession */
66
-	private $userSession;
67
-
68
-	public function __construct(GlobalStoragesService $globalService,
69
-						 UserStoragesService $userService,
70
-						 IUserManager $userManager,
71
-						 IUserSession $userSession,
72
-						 BackendService $backendService
73
-	) {
74
-		parent::__construct();
75
-		$this->globalService = $globalService;
76
-		$this->userService = $userService;
77
-		$this->userManager = $userManager;
78
-		$this->userSession = $userSession;
79
-		$this->backendService = $backendService;
80
-	}
81
-
82
-	protected function configure() {
83
-		$this
84
-			->setName('files_external:create')
85
-			->setDescription('Create a new mount configuration')
86
-			->addOption(
87
-				'user',
88
-				'',
89
-				InputOption::VALUE_OPTIONAL,
90
-				'user to add the mount configuration for, if not set the mount will be added as system mount'
91
-			)
92
-			->addArgument(
93
-				'mount_point',
94
-				InputArgument::REQUIRED,
95
-				'mount point for the new mount'
96
-			)
97
-			->addArgument(
98
-				'storage_backend',
99
-				InputArgument::REQUIRED,
100
-				'storage backend identifier for the new mount, see `occ files_external:backends` for possible values'
101
-			)
102
-			->addArgument(
103
-				'authentication_backend',
104
-				InputArgument::REQUIRED,
105
-				'authentication backend identifier for the new mount, see `occ files_external:backends` for possible values'
106
-			)
107
-			->addOption(
108
-				'config',
109
-				'c',
110
-				InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
111
-				'Mount configuration option in key=value format'
112
-			)
113
-			->addOption(
114
-				'dry',
115
-				'',
116
-				InputOption::VALUE_NONE,
117
-				'Don\'t save the created mount, only list the new mount'
118
-			);
119
-		parent::configure();
120
-	}
121
-
122
-	protected function execute(InputInterface $input, OutputInterface $output): int {
123
-		$user = $input->getOption('user');
124
-		$mountPoint = $input->getArgument('mount_point');
125
-		$storageIdentifier = $input->getArgument('storage_backend');
126
-		$authIdentifier = $input->getArgument('authentication_backend');
127
-		$configInput = $input->getOption('config');
128
-
129
-		$storageBackend = $this->backendService->getBackend($storageIdentifier);
130
-		$authBackend = $this->backendService->getAuthMechanism($authIdentifier);
131
-
132
-		if (!Filesystem::isValidPath($mountPoint)) {
133
-			$output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>');
134
-			return 1;
135
-		}
136
-		if (is_null($storageBackend)) {
137
-			$output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
138
-			return 404;
139
-		}
140
-		if (is_null($authBackend)) {
141
-			$output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
142
-			return 404;
143
-		}
144
-		$supportedSchemes = array_keys($storageBackend->getAuthSchemes());
145
-		if (!in_array($authBackend->getScheme(), $supportedSchemes)) {
146
-			$output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>');
147
-			return 1;
148
-		}
149
-
150
-		$config = [];
151
-		foreach ($configInput as $configOption) {
152
-			if (!strpos($configOption, '=')) {
153
-				$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
154
-				return 1;
155
-			}
156
-			list($key, $value) = explode('=', $configOption, 2);
157
-			if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) {
158
-				$output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>');
159
-				return 1;
160
-			}
161
-			$config[$key] = $value;
162
-		}
163
-
164
-		$mount = new StorageConfig();
165
-		$mount->setMountPoint($mountPoint);
166
-		$mount->setBackend($storageBackend);
167
-		$mount->setAuthMechanism($authBackend);
168
-		$mount->setBackendOptions($config);
169
-
170
-		if ($user) {
171
-			if (!$this->userManager->userExists($user)) {
172
-				$output->writeln('<error>User "' . $user . '" not found</error>');
173
-				return 1;
174
-			}
175
-			$mount->setApplicableUsers([$user]);
176
-		}
177
-
178
-		if ($input->getOption('dry')) {
179
-			$this->showMount($user, $mount, $input, $output);
180
-		} else {
181
-			$this->getStorageService($user)->addStorage($mount);
182
-			if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
183
-				$output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>');
184
-			} else {
185
-				$output->writeln((string)$mount->getId());
186
-			}
187
-		}
188
-		return 0;
189
-	}
190
-
191
-	private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend) {
192
-		$params = array_merge($storageBackend->getParameters(), $authBackend->getParameters());
193
-		foreach ($params as $param) {
194
-			/** @var DefinitionParameter $param */
195
-			if ($param->getName() === $key) {
196
-				if ($param->getType() === DefinitionParameter::VALUE_BOOLEAN) {
197
-					$value = ($value === 'true');
198
-				}
199
-				return true;
200
-			}
201
-		}
202
-		return false;
203
-	}
204
-
205
-	private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) {
206
-		$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
207
-		$listInput = new ArrayInput([], $listCommand->getDefinition());
208
-		$listInput->setOption('output', $input->getOption('output'));
209
-		$listInput->setOption('show-password', true);
210
-		$listCommand->listMounts($user, [$mount], $listInput, $output);
211
-	}
212
-
213
-	protected function getStorageService($userId) {
214
-		if (!empty($userId)) {
215
-			$user = $this->userManager->get($userId);
216
-			if (is_null($user)) {
217
-				throw new NoUserException("user $userId not found");
218
-			}
219
-			$this->userSession->setUser($user);
220
-			return $this->userService;
221
-		} else {
222
-			return $this->globalService;
223
-		}
224
-	}
47
+    /**
48
+     * @var GlobalStoragesService
49
+     */
50
+    private $globalService;
51
+
52
+    /**
53
+     * @var UserStoragesService
54
+     */
55
+    private $userService;
56
+
57
+    /**
58
+     * @var IUserManager
59
+     */
60
+    private $userManager;
61
+
62
+    /** @var BackendService */
63
+    private $backendService;
64
+
65
+    /** @var IUserSession */
66
+    private $userSession;
67
+
68
+    public function __construct(GlobalStoragesService $globalService,
69
+                            UserStoragesService $userService,
70
+                            IUserManager $userManager,
71
+                            IUserSession $userSession,
72
+                            BackendService $backendService
73
+    ) {
74
+        parent::__construct();
75
+        $this->globalService = $globalService;
76
+        $this->userService = $userService;
77
+        $this->userManager = $userManager;
78
+        $this->userSession = $userSession;
79
+        $this->backendService = $backendService;
80
+    }
81
+
82
+    protected function configure() {
83
+        $this
84
+            ->setName('files_external:create')
85
+            ->setDescription('Create a new mount configuration')
86
+            ->addOption(
87
+                'user',
88
+                '',
89
+                InputOption::VALUE_OPTIONAL,
90
+                'user to add the mount configuration for, if not set the mount will be added as system mount'
91
+            )
92
+            ->addArgument(
93
+                'mount_point',
94
+                InputArgument::REQUIRED,
95
+                'mount point for the new mount'
96
+            )
97
+            ->addArgument(
98
+                'storage_backend',
99
+                InputArgument::REQUIRED,
100
+                'storage backend identifier for the new mount, see `occ files_external:backends` for possible values'
101
+            )
102
+            ->addArgument(
103
+                'authentication_backend',
104
+                InputArgument::REQUIRED,
105
+                'authentication backend identifier for the new mount, see `occ files_external:backends` for possible values'
106
+            )
107
+            ->addOption(
108
+                'config',
109
+                'c',
110
+                InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
111
+                'Mount configuration option in key=value format'
112
+            )
113
+            ->addOption(
114
+                'dry',
115
+                '',
116
+                InputOption::VALUE_NONE,
117
+                'Don\'t save the created mount, only list the new mount'
118
+            );
119
+        parent::configure();
120
+    }
121
+
122
+    protected function execute(InputInterface $input, OutputInterface $output): int {
123
+        $user = $input->getOption('user');
124
+        $mountPoint = $input->getArgument('mount_point');
125
+        $storageIdentifier = $input->getArgument('storage_backend');
126
+        $authIdentifier = $input->getArgument('authentication_backend');
127
+        $configInput = $input->getOption('config');
128
+
129
+        $storageBackend = $this->backendService->getBackend($storageIdentifier);
130
+        $authBackend = $this->backendService->getAuthMechanism($authIdentifier);
131
+
132
+        if (!Filesystem::isValidPath($mountPoint)) {
133
+            $output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>');
134
+            return 1;
135
+        }
136
+        if (is_null($storageBackend)) {
137
+            $output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
138
+            return 404;
139
+        }
140
+        if (is_null($authBackend)) {
141
+            $output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
142
+            return 404;
143
+        }
144
+        $supportedSchemes = array_keys($storageBackend->getAuthSchemes());
145
+        if (!in_array($authBackend->getScheme(), $supportedSchemes)) {
146
+            $output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>');
147
+            return 1;
148
+        }
149
+
150
+        $config = [];
151
+        foreach ($configInput as $configOption) {
152
+            if (!strpos($configOption, '=')) {
153
+                $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
154
+                return 1;
155
+            }
156
+            list($key, $value) = explode('=', $configOption, 2);
157
+            if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) {
158
+                $output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>');
159
+                return 1;
160
+            }
161
+            $config[$key] = $value;
162
+        }
163
+
164
+        $mount = new StorageConfig();
165
+        $mount->setMountPoint($mountPoint);
166
+        $mount->setBackend($storageBackend);
167
+        $mount->setAuthMechanism($authBackend);
168
+        $mount->setBackendOptions($config);
169
+
170
+        if ($user) {
171
+            if (!$this->userManager->userExists($user)) {
172
+                $output->writeln('<error>User "' . $user . '" not found</error>');
173
+                return 1;
174
+            }
175
+            $mount->setApplicableUsers([$user]);
176
+        }
177
+
178
+        if ($input->getOption('dry')) {
179
+            $this->showMount($user, $mount, $input, $output);
180
+        } else {
181
+            $this->getStorageService($user)->addStorage($mount);
182
+            if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
183
+                $output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>');
184
+            } else {
185
+                $output->writeln((string)$mount->getId());
186
+            }
187
+        }
188
+        return 0;
189
+    }
190
+
191
+    private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend) {
192
+        $params = array_merge($storageBackend->getParameters(), $authBackend->getParameters());
193
+        foreach ($params as $param) {
194
+            /** @var DefinitionParameter $param */
195
+            if ($param->getName() === $key) {
196
+                if ($param->getType() === DefinitionParameter::VALUE_BOOLEAN) {
197
+                    $value = ($value === 'true');
198
+                }
199
+                return true;
200
+            }
201
+        }
202
+        return false;
203
+    }
204
+
205
+    private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) {
206
+        $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
207
+        $listInput = new ArrayInput([], $listCommand->getDefinition());
208
+        $listInput->setOption('output', $input->getOption('output'));
209
+        $listInput->setOption('show-password', true);
210
+        $listCommand->listMounts($user, [$mount], $listInput, $output);
211
+    }
212
+
213
+    protected function getStorageService($userId) {
214
+        if (!empty($userId)) {
215
+            $user = $this->userManager->get($userId);
216
+            if (is_null($user)) {
217
+                throw new NoUserException("user $userId not found");
218
+            }
219
+            $this->userSession->setUser($user);
220
+            return $this->userService;
221
+        } else {
222
+            return $this->globalService;
223
+        }
224
+    }
225 225
 }
Please login to merge, or discard this patch.
lib/public/Util.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -304,9 +304,9 @@
 block discarded – undo
304 304
 	 */
305 305
 	public static function linkToRemote($service) {
306 306
 		$urlGenerator = \OC::$server->getURLGenerator();
307
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
307
+		$remoteBase = $urlGenerator->linkTo('', 'remote.php').'/'.$service;
308 308
 		return $urlGenerator->getAbsoluteURL(
309
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
309
+			$remoteBase.(($service[strlen($service) - 1] != '/') ? '/' : '')
310 310
 		);
311 311
 	}
312 312
 
Please login to merge, or discard this patch.
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -57,474 +57,474 @@
 block discarded – undo
57 57
  * @since 4.0.0
58 58
  */
59 59
 class Util {
60
-	/**
61
-	 * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
62
-	 */
63
-	public const DEBUG = 0;
64
-	/**
65
-	 * @deprecated 14.0.0 use \OCP\ILogger::INFO
66
-	 */
67
-	public const INFO = 1;
68
-	/**
69
-	 * @deprecated 14.0.0 use \OCP\ILogger::WARN
70
-	 */
71
-	public const WARN = 2;
72
-	/**
73
-	 * @deprecated 14.0.0 use \OCP\ILogger::ERROR
74
-	 */
75
-	public const ERROR = 3;
76
-	/**
77
-	 * @deprecated 14.0.0 use \OCP\ILogger::FATAL
78
-	 */
79
-	public const FATAL = 4;
80
-
81
-	/** \OCP\Share\IManager */
82
-	private static $shareManager;
83
-
84
-	/**
85
-	 * get the current installed version of Nextcloud
86
-	 * @return array
87
-	 * @since 4.0.0
88
-	 */
89
-	public static function getVersion() {
90
-		return \OC_Util::getVersion();
91
-	}
92
-
93
-	/**
94
-	 * @since 17.0.0
95
-	 */
96
-	public static function hasExtendedSupport(): bool {
97
-		try {
98
-			/** @var \OCP\Support\Subscription\IRegistry */
99
-			$subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
100
-			return $subscriptionRegistry->delegateHasExtendedSupport();
101
-		} catch (AppFramework\QueryException $e) {
102
-		}
103
-		return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
104
-	}
105
-
106
-	/**
107
-	 * Set current update channel
108
-	 * @param string $channel
109
-	 * @since 8.1.0
110
-	 */
111
-	public static function setChannel($channel) {
112
-		\OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
113
-	}
114
-
115
-	/**
116
-	 * Get current update channel
117
-	 * @return string
118
-	 * @since 8.1.0
119
-	 */
120
-	public static function getChannel() {
121
-		return \OC_Util::getChannel();
122
-	}
123
-
124
-	/**
125
-	 * write a message in the log
126
-	 * @param string $app
127
-	 * @param string $message
128
-	 * @param int $level
129
-	 * @since 4.0.0
130
-	 * @deprecated 13.0.0 use log of \OCP\ILogger
131
-	 */
132
-	public static function writeLog($app, $message, $level) {
133
-		$context = ['app' => $app];
134
-		\OC::$server->getLogger()->log($level, $message, $context);
135
-	}
136
-
137
-	/**
138
-	 * check if sharing is disabled for the current user
139
-	 *
140
-	 * @return boolean
141
-	 * @since 7.0.0
142
-	 * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
143
-	 */
144
-	public static function isSharingDisabledForUser() {
145
-		if (self::$shareManager === null) {
146
-			self::$shareManager = \OC::$server->getShareManager();
147
-		}
148
-
149
-		$user = \OC::$server->getUserSession()->getUser();
150
-		if ($user !== null) {
151
-			$user = $user->getUID();
152
-		}
153
-
154
-		return self::$shareManager->sharingDisabledForUser($user);
155
-	}
156
-
157
-	/**
158
-	 * get l10n object
159
-	 * @param string $application
160
-	 * @param string|null $language
161
-	 * @return \OCP\IL10N
162
-	 * @since 6.0.0 - parameter $language was added in 8.0.0
163
-	 */
164
-	public static function getL10N($application, $language = null) {
165
-		return \OC::$server->getL10N($application, $language);
166
-	}
167
-
168
-	/**
169
-	 * add a css file
170
-	 * @param string $application
171
-	 * @param string $file
172
-	 * @since 4.0.0
173
-	 */
174
-	public static function addStyle($application, $file = null) {
175
-		\OC_Util::addStyle($application, $file);
176
-	}
177
-
178
-	/**
179
-	 * add a javascript file
180
-	 * @param string $application
181
-	 * @param string $file
182
-	 * @since 4.0.0
183
-	 */
184
-	public static function addScript($application, $file = null) {
185
-		\OC_Util::addScript($application, $file);
186
-	}
187
-
188
-	/**
189
-	 * Add a translation JS file
190
-	 * @param string $application application id
191
-	 * @param string $languageCode language code, defaults to the current locale
192
-	 * @since 8.0.0
193
-	 */
194
-	public static function addTranslations($application, $languageCode = null) {
195
-		\OC_Util::addTranslations($application, $languageCode);
196
-	}
197
-
198
-	/**
199
-	 * Add a custom element to the header
200
-	 * If $text is null then the element will be written as empty element.
201
-	 * So use "" to get a closing tag.
202
-	 * @param string $tag tag name of the element
203
-	 * @param array $attributes array of attributes for the element
204
-	 * @param string $text the text content for the element
205
-	 * @since 4.0.0
206
-	 */
207
-	public static function addHeader($tag, $attributes, $text = null) {
208
-		\OC_Util::addHeader($tag, $attributes, $text);
209
-	}
210
-
211
-	/**
212
-	 * Creates an absolute url to the given app and file.
213
-	 * @param string $app app
214
-	 * @param string $file file
215
-	 * @param array $args array with param=>value, will be appended to the returned url
216
-	 * 	The value of $args will be urlencoded
217
-	 * @return string the url
218
-	 * @since 4.0.0 - parameter $args was added in 4.5.0
219
-	 */
220
-	public static function linkToAbsolute($app, $file, $args = []) {
221
-		$urlGenerator = \OC::$server->getURLGenerator();
222
-		return $urlGenerator->getAbsoluteURL(
223
-			$urlGenerator->linkTo($app, $file, $args)
224
-		);
225
-	}
226
-
227
-	/**
228
-	 * Creates an absolute url for remote use.
229
-	 * @param string $service id
230
-	 * @return string the url
231
-	 * @since 4.0.0
232
-	 */
233
-	public static function linkToRemote($service) {
234
-		$urlGenerator = \OC::$server->getURLGenerator();
235
-		$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
236
-		return $urlGenerator->getAbsoluteURL(
237
-			$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
238
-		);
239
-	}
240
-
241
-	/**
242
-	 * Creates an absolute url for public use
243
-	 * @param string $service id
244
-	 * @return string the url
245
-	 * @since 4.5.0
246
-	 * @deprecated 15.0.0 - use OCP\IURLGenerator
247
-	 */
248
-	public static function linkToPublic($service) {
249
-		$urlGenerator = \OC::$server->getURLGenerator();
250
-		if ($service === 'files') {
251
-			return $urlGenerator->getAbsoluteURL('/s');
252
-		}
253
-		return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
254
-	}
255
-
256
-	/**
257
-	 * Returns the server host name without an eventual port number
258
-	 * @return string the server hostname
259
-	 * @since 5.0.0
260
-	 */
261
-	public static function getServerHostName() {
262
-		$host_name = \OC::$server->getRequest()->getServerHost();
263
-		// strip away port number (if existing)
264
-		$colon_pos = strpos($host_name, ':');
265
-		if ($colon_pos != false) {
266
-			$host_name = substr($host_name, 0, $colon_pos);
267
-		}
268
-		return $host_name;
269
-	}
270
-
271
-	/**
272
-	 * Returns the default email address
273
-	 * @param string $user_part the user part of the address
274
-	 * @return string the default email address
275
-	 *
276
-	 * Assembles a default email address (using the server hostname
277
-	 * and the given user part, and returns it
278
-	 * Example: when given lostpassword-noreply as $user_part param,
279
-	 *     and is currently accessed via http(s)://example.com/,
280
-	 *     it would return '[email protected]'
281
-	 *
282
-	 * If the configuration value 'mail_from_address' is set in
283
-	 * config.php, this value will override the $user_part that
284
-	 * is passed to this function
285
-	 * @since 5.0.0
286
-	 */
287
-	public static function getDefaultEmailAddress($user_part) {
288
-		$config = \OC::$server->getConfig();
289
-		$user_part = $config->getSystemValue('mail_from_address', $user_part);
290
-		$host_name = self::getServerHostName();
291
-		$host_name = $config->getSystemValue('mail_domain', $host_name);
292
-		$defaultEmailAddress = $user_part.'@'.$host_name;
293
-
294
-		$mailer = \OC::$server->getMailer();
295
-		if ($mailer->validateMailAddress($defaultEmailAddress)) {
296
-			return $defaultEmailAddress;
297
-		}
298
-
299
-		// in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
300
-		return $user_part.'@localhost.localdomain';
301
-	}
302
-
303
-	/**
304
-	 * Make a human file size (2048 to 2 kB)
305
-	 * @param int $bytes file size in bytes
306
-	 * @return string a human readable file size
307
-	 * @since 4.0.0
308
-	 */
309
-	public static function humanFileSize($bytes) {
310
-		return \OC_Helper::humanFileSize($bytes);
311
-	}
312
-
313
-	/**
314
-	 * Make a computer file size (2 kB to 2048)
315
-	 * @param string $str file size in a fancy format
316
-	 * @return float a file size in bytes
317
-	 *
318
-	 * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
319
-	 * @since 4.0.0
320
-	 */
321
-	public static function computerFileSize($str) {
322
-		return \OC_Helper::computerFileSize($str);
323
-	}
324
-
325
-	/**
326
-	 * connects a function to a hook
327
-	 *
328
-	 * @param string $signalClass class name of emitter
329
-	 * @param string $signalName name of signal
330
-	 * @param string|object $slotClass class name of slot
331
-	 * @param string $slotName name of slot
332
-	 * @return bool
333
-	 *
334
-	 * This function makes it very easy to connect to use hooks.
335
-	 *
336
-	 * TODO: write example
337
-	 * @since 4.0.0
338
-	 */
339
-	public static function connectHook($signalClass, $signalName, $slotClass, $slotName) {
340
-		return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
341
-	}
342
-
343
-	/**
344
-	 * Emits a signal. To get data from the slot use references!
345
-	 * @param string $signalclass class name of emitter
346
-	 * @param string $signalname name of signal
347
-	 * @param array $params default: array() array with additional data
348
-	 * @return bool true if slots exists or false if not
349
-	 *
350
-	 * TODO: write example
351
-	 * @since 4.0.0
352
-	 */
353
-	public static function emitHook($signalclass, $signalname, $params = []) {
354
-		return \OC_Hook::emit($signalclass, $signalname, $params);
355
-	}
356
-
357
-	/**
358
-	 * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
359
-	 * multiple OC_Template elements which invoke `callRegister`. If the value
360
-	 * would not be cached these unit-tests would fail.
361
-	 * @var string
362
-	 */
363
-	private static $token = '';
364
-
365
-	/**
366
-	 * Register an get/post call. This is important to prevent CSRF attacks
367
-	 * @since 4.5.0
368
-	 */
369
-	public static function callRegister() {
370
-		if (self::$token === '') {
371
-			self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
372
-		}
373
-		return self::$token;
374
-	}
375
-
376
-	/**
377
-	 * Used to sanitize HTML
378
-	 *
379
-	 * This function is used to sanitize HTML and should be applied on any
380
-	 * string or array of strings before displaying it on a web page.
381
-	 *
382
-	 * @param string|array $value
383
-	 * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
384
-	 * @since 4.5.0
385
-	 */
386
-	public static function sanitizeHTML($value) {
387
-		return \OC_Util::sanitizeHTML($value);
388
-	}
389
-
390
-	/**
391
-	 * Public function to encode url parameters
392
-	 *
393
-	 * This function is used to encode path to file before output.
394
-	 * Encoding is done according to RFC 3986 with one exception:
395
-	 * Character '/' is preserved as is.
396
-	 *
397
-	 * @param string $component part of URI to encode
398
-	 * @return string
399
-	 * @since 6.0.0
400
-	 */
401
-	public static function encodePath($component) {
402
-		return \OC_Util::encodePath($component);
403
-	}
404
-
405
-	/**
406
-	 * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
407
-	 *
408
-	 * @param array $input The array to work on
409
-	 * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
410
-	 * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
411
-	 * @return array
412
-	 * @since 4.5.0
413
-	 */
414
-	public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
415
-		return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
416
-	}
417
-
418
-	/**
419
-	 * performs a search in a nested array
420
-	 *
421
-	 * @param array $haystack the array to be searched
422
-	 * @param string $needle the search string
423
-	 * @param mixed $index optional, only search this key name
424
-	 * @return mixed the key of the matching field, otherwise false
425
-	 * @since 4.5.0
426
-	 * @deprecated 15.0.0
427
-	 */
428
-	public static function recursiveArraySearch($haystack, $needle, $index = null) {
429
-		return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
430
-	}
431
-
432
-	/**
433
-	 * calculates the maximum upload size respecting system settings, free space and user quota
434
-	 *
435
-	 * @param string $dir the current folder where the user currently operates
436
-	 * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
437
-	 * @return int number of bytes representing
438
-	 * @since 5.0.0
439
-	 */
440
-	public static function maxUploadFilesize($dir, $free = null) {
441
-		return \OC_Helper::maxUploadFilesize($dir, $free);
442
-	}
443
-
444
-	/**
445
-	 * Calculate free space left within user quota
446
-	 * @param string $dir the current folder where the user currently operates
447
-	 * @return int number of bytes representing
448
-	 * @since 7.0.0
449
-	 */
450
-	public static function freeSpace($dir) {
451
-		return \OC_Helper::freeSpace($dir);
452
-	}
453
-
454
-	/**
455
-	 * Calculate PHP upload limit
456
-	 *
457
-	 * @return int number of bytes representing
458
-	 * @since 7.0.0
459
-	 */
460
-	public static function uploadLimit() {
461
-		return \OC_Helper::uploadLimit();
462
-	}
463
-
464
-	/**
465
-	 * Returns whether the given file name is valid
466
-	 * @param string $file file name to check
467
-	 * @return bool true if the file name is valid, false otherwise
468
-	 * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
469
-	 * @since 7.0.0
470
-	 * @suppress PhanDeprecatedFunction
471
-	 */
472
-	public static function isValidFileName($file) {
473
-		return \OC_Util::isValidFileName($file);
474
-	}
475
-
476
-	/**
477
-	 * Compare two strings to provide a natural sort
478
-	 * @param string $a first string to compare
479
-	 * @param string $b second string to compare
480
-	 * @return int -1 if $b comes before $a, 1 if $a comes before $b
481
-	 * or 0 if the strings are identical
482
-	 * @since 7.0.0
483
-	 */
484
-	public static function naturalSortCompare($a, $b) {
485
-		return \OC\NaturalSort::getInstance()->compare($a, $b);
486
-	}
487
-
488
-	/**
489
-	 * check if a password is required for each public link
490
-	 * @return boolean
491
-	 * @since 7.0.0
492
-	 */
493
-	public static function isPublicLinkPasswordRequired() {
494
-		return \OC_Util::isPublicLinkPasswordRequired();
495
-	}
496
-
497
-	/**
498
-	 * check if share API enforces a default expire date
499
-	 * @return boolean
500
-	 * @since 8.0.0
501
-	 */
502
-	public static function isDefaultExpireDateEnforced() {
503
-		return \OC_Util::isDefaultExpireDateEnforced();
504
-	}
505
-
506
-	protected static $needUpgradeCache = null;
507
-
508
-	/**
509
-	 * Checks whether the current version needs upgrade.
510
-	 *
511
-	 * @return bool true if upgrade is needed, false otherwise
512
-	 * @since 7.0.0
513
-	 */
514
-	public static function needUpgrade() {
515
-		if (!isset(self::$needUpgradeCache)) {
516
-			self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
517
-		}
518
-		return self::$needUpgradeCache;
519
-	}
520
-
521
-	/**
522
-	 * is this Internet explorer ?
523
-	 *
524
-	 * @return boolean
525
-	 * @since 14.0.0
526
-	 */
527
-	public static function isIe() {
528
-		return \OC_Util::isIe();
529
-	}
60
+    /**
61
+     * @deprecated 14.0.0 use \OCP\ILogger::DEBUG
62
+     */
63
+    public const DEBUG = 0;
64
+    /**
65
+     * @deprecated 14.0.0 use \OCP\ILogger::INFO
66
+     */
67
+    public const INFO = 1;
68
+    /**
69
+     * @deprecated 14.0.0 use \OCP\ILogger::WARN
70
+     */
71
+    public const WARN = 2;
72
+    /**
73
+     * @deprecated 14.0.0 use \OCP\ILogger::ERROR
74
+     */
75
+    public const ERROR = 3;
76
+    /**
77
+     * @deprecated 14.0.0 use \OCP\ILogger::FATAL
78
+     */
79
+    public const FATAL = 4;
80
+
81
+    /** \OCP\Share\IManager */
82
+    private static $shareManager;
83
+
84
+    /**
85
+     * get the current installed version of Nextcloud
86
+     * @return array
87
+     * @since 4.0.0
88
+     */
89
+    public static function getVersion() {
90
+        return \OC_Util::getVersion();
91
+    }
92
+
93
+    /**
94
+     * @since 17.0.0
95
+     */
96
+    public static function hasExtendedSupport(): bool {
97
+        try {
98
+            /** @var \OCP\Support\Subscription\IRegistry */
99
+            $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
100
+            return $subscriptionRegistry->delegateHasExtendedSupport();
101
+        } catch (AppFramework\QueryException $e) {
102
+        }
103
+        return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
104
+    }
105
+
106
+    /**
107
+     * Set current update channel
108
+     * @param string $channel
109
+     * @since 8.1.0
110
+     */
111
+    public static function setChannel($channel) {
112
+        \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
113
+    }
114
+
115
+    /**
116
+     * Get current update channel
117
+     * @return string
118
+     * @since 8.1.0
119
+     */
120
+    public static function getChannel() {
121
+        return \OC_Util::getChannel();
122
+    }
123
+
124
+    /**
125
+     * write a message in the log
126
+     * @param string $app
127
+     * @param string $message
128
+     * @param int $level
129
+     * @since 4.0.0
130
+     * @deprecated 13.0.0 use log of \OCP\ILogger
131
+     */
132
+    public static function writeLog($app, $message, $level) {
133
+        $context = ['app' => $app];
134
+        \OC::$server->getLogger()->log($level, $message, $context);
135
+    }
136
+
137
+    /**
138
+     * check if sharing is disabled for the current user
139
+     *
140
+     * @return boolean
141
+     * @since 7.0.0
142
+     * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser
143
+     */
144
+    public static function isSharingDisabledForUser() {
145
+        if (self::$shareManager === null) {
146
+            self::$shareManager = \OC::$server->getShareManager();
147
+        }
148
+
149
+        $user = \OC::$server->getUserSession()->getUser();
150
+        if ($user !== null) {
151
+            $user = $user->getUID();
152
+        }
153
+
154
+        return self::$shareManager->sharingDisabledForUser($user);
155
+    }
156
+
157
+    /**
158
+     * get l10n object
159
+     * @param string $application
160
+     * @param string|null $language
161
+     * @return \OCP\IL10N
162
+     * @since 6.0.0 - parameter $language was added in 8.0.0
163
+     */
164
+    public static function getL10N($application, $language = null) {
165
+        return \OC::$server->getL10N($application, $language);
166
+    }
167
+
168
+    /**
169
+     * add a css file
170
+     * @param string $application
171
+     * @param string $file
172
+     * @since 4.0.0
173
+     */
174
+    public static function addStyle($application, $file = null) {
175
+        \OC_Util::addStyle($application, $file);
176
+    }
177
+
178
+    /**
179
+     * add a javascript file
180
+     * @param string $application
181
+     * @param string $file
182
+     * @since 4.0.0
183
+     */
184
+    public static function addScript($application, $file = null) {
185
+        \OC_Util::addScript($application, $file);
186
+    }
187
+
188
+    /**
189
+     * Add a translation JS file
190
+     * @param string $application application id
191
+     * @param string $languageCode language code, defaults to the current locale
192
+     * @since 8.0.0
193
+     */
194
+    public static function addTranslations($application, $languageCode = null) {
195
+        \OC_Util::addTranslations($application, $languageCode);
196
+    }
197
+
198
+    /**
199
+     * Add a custom element to the header
200
+     * If $text is null then the element will be written as empty element.
201
+     * So use "" to get a closing tag.
202
+     * @param string $tag tag name of the element
203
+     * @param array $attributes array of attributes for the element
204
+     * @param string $text the text content for the element
205
+     * @since 4.0.0
206
+     */
207
+    public static function addHeader($tag, $attributes, $text = null) {
208
+        \OC_Util::addHeader($tag, $attributes, $text);
209
+    }
210
+
211
+    /**
212
+     * Creates an absolute url to the given app and file.
213
+     * @param string $app app
214
+     * @param string $file file
215
+     * @param array $args array with param=>value, will be appended to the returned url
216
+     * 	The value of $args will be urlencoded
217
+     * @return string the url
218
+     * @since 4.0.0 - parameter $args was added in 4.5.0
219
+     */
220
+    public static function linkToAbsolute($app, $file, $args = []) {
221
+        $urlGenerator = \OC::$server->getURLGenerator();
222
+        return $urlGenerator->getAbsoluteURL(
223
+            $urlGenerator->linkTo($app, $file, $args)
224
+        );
225
+    }
226
+
227
+    /**
228
+     * Creates an absolute url for remote use.
229
+     * @param string $service id
230
+     * @return string the url
231
+     * @since 4.0.0
232
+     */
233
+    public static function linkToRemote($service) {
234
+        $urlGenerator = \OC::$server->getURLGenerator();
235
+        $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
236
+        return $urlGenerator->getAbsoluteURL(
237
+            $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
238
+        );
239
+    }
240
+
241
+    /**
242
+     * Creates an absolute url for public use
243
+     * @param string $service id
244
+     * @return string the url
245
+     * @since 4.5.0
246
+     * @deprecated 15.0.0 - use OCP\IURLGenerator
247
+     */
248
+    public static function linkToPublic($service) {
249
+        $urlGenerator = \OC::$server->getURLGenerator();
250
+        if ($service === 'files') {
251
+            return $urlGenerator->getAbsoluteURL('/s');
252
+        }
253
+        return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service);
254
+    }
255
+
256
+    /**
257
+     * Returns the server host name without an eventual port number
258
+     * @return string the server hostname
259
+     * @since 5.0.0
260
+     */
261
+    public static function getServerHostName() {
262
+        $host_name = \OC::$server->getRequest()->getServerHost();
263
+        // strip away port number (if existing)
264
+        $colon_pos = strpos($host_name, ':');
265
+        if ($colon_pos != false) {
266
+            $host_name = substr($host_name, 0, $colon_pos);
267
+        }
268
+        return $host_name;
269
+    }
270
+
271
+    /**
272
+     * Returns the default email address
273
+     * @param string $user_part the user part of the address
274
+     * @return string the default email address
275
+     *
276
+     * Assembles a default email address (using the server hostname
277
+     * and the given user part, and returns it
278
+     * Example: when given lostpassword-noreply as $user_part param,
279
+     *     and is currently accessed via http(s)://example.com/,
280
+     *     it would return '[email protected]'
281
+     *
282
+     * If the configuration value 'mail_from_address' is set in
283
+     * config.php, this value will override the $user_part that
284
+     * is passed to this function
285
+     * @since 5.0.0
286
+     */
287
+    public static function getDefaultEmailAddress($user_part) {
288
+        $config = \OC::$server->getConfig();
289
+        $user_part = $config->getSystemValue('mail_from_address', $user_part);
290
+        $host_name = self::getServerHostName();
291
+        $host_name = $config->getSystemValue('mail_domain', $host_name);
292
+        $defaultEmailAddress = $user_part.'@'.$host_name;
293
+
294
+        $mailer = \OC::$server->getMailer();
295
+        if ($mailer->validateMailAddress($defaultEmailAddress)) {
296
+            return $defaultEmailAddress;
297
+        }
298
+
299
+        // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
300
+        return $user_part.'@localhost.localdomain';
301
+    }
302
+
303
+    /**
304
+     * Make a human file size (2048 to 2 kB)
305
+     * @param int $bytes file size in bytes
306
+     * @return string a human readable file size
307
+     * @since 4.0.0
308
+     */
309
+    public static function humanFileSize($bytes) {
310
+        return \OC_Helper::humanFileSize($bytes);
311
+    }
312
+
313
+    /**
314
+     * Make a computer file size (2 kB to 2048)
315
+     * @param string $str file size in a fancy format
316
+     * @return float a file size in bytes
317
+     *
318
+     * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
319
+     * @since 4.0.0
320
+     */
321
+    public static function computerFileSize($str) {
322
+        return \OC_Helper::computerFileSize($str);
323
+    }
324
+
325
+    /**
326
+     * connects a function to a hook
327
+     *
328
+     * @param string $signalClass class name of emitter
329
+     * @param string $signalName name of signal
330
+     * @param string|object $slotClass class name of slot
331
+     * @param string $slotName name of slot
332
+     * @return bool
333
+     *
334
+     * This function makes it very easy to connect to use hooks.
335
+     *
336
+     * TODO: write example
337
+     * @since 4.0.0
338
+     */
339
+    public static function connectHook($signalClass, $signalName, $slotClass, $slotName) {
340
+        return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName);
341
+    }
342
+
343
+    /**
344
+     * Emits a signal. To get data from the slot use references!
345
+     * @param string $signalclass class name of emitter
346
+     * @param string $signalname name of signal
347
+     * @param array $params default: array() array with additional data
348
+     * @return bool true if slots exists or false if not
349
+     *
350
+     * TODO: write example
351
+     * @since 4.0.0
352
+     */
353
+    public static function emitHook($signalclass, $signalname, $params = []) {
354
+        return \OC_Hook::emit($signalclass, $signalname, $params);
355
+    }
356
+
357
+    /**
358
+     * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare
359
+     * multiple OC_Template elements which invoke `callRegister`. If the value
360
+     * would not be cached these unit-tests would fail.
361
+     * @var string
362
+     */
363
+    private static $token = '';
364
+
365
+    /**
366
+     * Register an get/post call. This is important to prevent CSRF attacks
367
+     * @since 4.5.0
368
+     */
369
+    public static function callRegister() {
370
+        if (self::$token === '') {
371
+            self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue();
372
+        }
373
+        return self::$token;
374
+    }
375
+
376
+    /**
377
+     * Used to sanitize HTML
378
+     *
379
+     * This function is used to sanitize HTML and should be applied on any
380
+     * string or array of strings before displaying it on a web page.
381
+     *
382
+     * @param string|array $value
383
+     * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
384
+     * @since 4.5.0
385
+     */
386
+    public static function sanitizeHTML($value) {
387
+        return \OC_Util::sanitizeHTML($value);
388
+    }
389
+
390
+    /**
391
+     * Public function to encode url parameters
392
+     *
393
+     * This function is used to encode path to file before output.
394
+     * Encoding is done according to RFC 3986 with one exception:
395
+     * Character '/' is preserved as is.
396
+     *
397
+     * @param string $component part of URI to encode
398
+     * @return string
399
+     * @since 6.0.0
400
+     */
401
+    public static function encodePath($component) {
402
+        return \OC_Util::encodePath($component);
403
+    }
404
+
405
+    /**
406
+     * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
407
+     *
408
+     * @param array $input The array to work on
409
+     * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
410
+     * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
411
+     * @return array
412
+     * @since 4.5.0
413
+     */
414
+    public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
415
+        return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
416
+    }
417
+
418
+    /**
419
+     * performs a search in a nested array
420
+     *
421
+     * @param array $haystack the array to be searched
422
+     * @param string $needle the search string
423
+     * @param mixed $index optional, only search this key name
424
+     * @return mixed the key of the matching field, otherwise false
425
+     * @since 4.5.0
426
+     * @deprecated 15.0.0
427
+     */
428
+    public static function recursiveArraySearch($haystack, $needle, $index = null) {
429
+        return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
430
+    }
431
+
432
+    /**
433
+     * calculates the maximum upload size respecting system settings, free space and user quota
434
+     *
435
+     * @param string $dir the current folder where the user currently operates
436
+     * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
437
+     * @return int number of bytes representing
438
+     * @since 5.0.0
439
+     */
440
+    public static function maxUploadFilesize($dir, $free = null) {
441
+        return \OC_Helper::maxUploadFilesize($dir, $free);
442
+    }
443
+
444
+    /**
445
+     * Calculate free space left within user quota
446
+     * @param string $dir the current folder where the user currently operates
447
+     * @return int number of bytes representing
448
+     * @since 7.0.0
449
+     */
450
+    public static function freeSpace($dir) {
451
+        return \OC_Helper::freeSpace($dir);
452
+    }
453
+
454
+    /**
455
+     * Calculate PHP upload limit
456
+     *
457
+     * @return int number of bytes representing
458
+     * @since 7.0.0
459
+     */
460
+    public static function uploadLimit() {
461
+        return \OC_Helper::uploadLimit();
462
+    }
463
+
464
+    /**
465
+     * Returns whether the given file name is valid
466
+     * @param string $file file name to check
467
+     * @return bool true if the file name is valid, false otherwise
468
+     * @deprecated 8.1.0 use \OC\Files\View::verifyPath()
469
+     * @since 7.0.0
470
+     * @suppress PhanDeprecatedFunction
471
+     */
472
+    public static function isValidFileName($file) {
473
+        return \OC_Util::isValidFileName($file);
474
+    }
475
+
476
+    /**
477
+     * Compare two strings to provide a natural sort
478
+     * @param string $a first string to compare
479
+     * @param string $b second string to compare
480
+     * @return int -1 if $b comes before $a, 1 if $a comes before $b
481
+     * or 0 if the strings are identical
482
+     * @since 7.0.0
483
+     */
484
+    public static function naturalSortCompare($a, $b) {
485
+        return \OC\NaturalSort::getInstance()->compare($a, $b);
486
+    }
487
+
488
+    /**
489
+     * check if a password is required for each public link
490
+     * @return boolean
491
+     * @since 7.0.0
492
+     */
493
+    public static function isPublicLinkPasswordRequired() {
494
+        return \OC_Util::isPublicLinkPasswordRequired();
495
+    }
496
+
497
+    /**
498
+     * check if share API enforces a default expire date
499
+     * @return boolean
500
+     * @since 8.0.0
501
+     */
502
+    public static function isDefaultExpireDateEnforced() {
503
+        return \OC_Util::isDefaultExpireDateEnforced();
504
+    }
505
+
506
+    protected static $needUpgradeCache = null;
507
+
508
+    /**
509
+     * Checks whether the current version needs upgrade.
510
+     *
511
+     * @return bool true if upgrade is needed, false otherwise
512
+     * @since 7.0.0
513
+     */
514
+    public static function needUpgrade() {
515
+        if (!isset(self::$needUpgradeCache)) {
516
+            self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
517
+        }
518
+        return self::$needUpgradeCache;
519
+    }
520
+
521
+    /**
522
+     * is this Internet explorer ?
523
+     *
524
+     * @return boolean
525
+     * @since 14.0.0
526
+     */
527
+    public static function isIe() {
528
+        return \OC_Util::isIe();
529
+    }
530 530
 }
Please login to merge, or discard this patch.
lib/public/Route/IRouter.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -36,91 +36,91 @@
 block discarded – undo
36 36
  */
37 37
 interface IRouter {
38 38
 
39
-	/**
40
-	 * Get the files to load the routes from
41
-	 *
42
-	 * @return string[]
43
-	 * @since 7.0.0
44
-	 * @deprecated 9.0.0
45
-	 */
46
-	public function getRoutingFiles();
39
+    /**
40
+     * Get the files to load the routes from
41
+     *
42
+     * @return string[]
43
+     * @since 7.0.0
44
+     * @deprecated 9.0.0
45
+     */
46
+    public function getRoutingFiles();
47 47
 
48
-	/**
49
-	 * @return string
50
-	 * @since 7.0.0
51
-	 * @deprecated 9.0.0
52
-	 */
53
-	public function getCacheKey();
48
+    /**
49
+     * @return string
50
+     * @since 7.0.0
51
+     * @deprecated 9.0.0
52
+     */
53
+    public function getCacheKey();
54 54
 
55
-	/**
56
-	 * Loads the routes
57
-	 *
58
-	 * @param null|string $app
59
-	 * @since 7.0.0
60
-	 * @deprecated 9.0.0
61
-	 */
62
-	public function loadRoutes($app = null);
55
+    /**
56
+     * Loads the routes
57
+     *
58
+     * @param null|string $app
59
+     * @since 7.0.0
60
+     * @deprecated 9.0.0
61
+     */
62
+    public function loadRoutes($app = null);
63 63
 
64
-	/**
65
-	 * Sets the collection to use for adding routes
66
-	 *
67
-	 * @param string $name Name of the collection to use.
68
-	 * @return void
69
-	 * @since 7.0.0
70
-	 * @deprecated 9.0.0
71
-	 */
72
-	public function useCollection($name);
64
+    /**
65
+     * Sets the collection to use for adding routes
66
+     *
67
+     * @param string $name Name of the collection to use.
68
+     * @return void
69
+     * @since 7.0.0
70
+     * @deprecated 9.0.0
71
+     */
72
+    public function useCollection($name);
73 73
 
74
-	/**
75
-	 * returns the current collection name in use for adding routes
76
-	 *
77
-	 * @return string the collection name
78
-	 * @since 8.0.0
79
-	 * @deprecated 9.0.0
80
-	 */
81
-	public function getCurrentCollection();
74
+    /**
75
+     * returns the current collection name in use for adding routes
76
+     *
77
+     * @return string the collection name
78
+     * @since 8.0.0
79
+     * @deprecated 9.0.0
80
+     */
81
+    public function getCurrentCollection();
82 82
 
83
-	/**
84
-	 * Create a \OCP\Route\IRoute.
85
-	 *
86
-	 * @param string $name Name of the route to create.
87
-	 * @param string $pattern The pattern to match
88
-	 * @param array $defaults An array of default parameter values
89
-	 * @param array $requirements An array of requirements for parameters (regexes)
90
-	 * @return \OCP\Route\IRoute
91
-	 * @since 7.0.0
92
-	 * @deprecated 9.0.0
93
-	 */
94
-	public function create($name, $pattern, array $defaults = [], array $requirements = []);
83
+    /**
84
+     * Create a \OCP\Route\IRoute.
85
+     *
86
+     * @param string $name Name of the route to create.
87
+     * @param string $pattern The pattern to match
88
+     * @param array $defaults An array of default parameter values
89
+     * @param array $requirements An array of requirements for parameters (regexes)
90
+     * @return \OCP\Route\IRoute
91
+     * @since 7.0.0
92
+     * @deprecated 9.0.0
93
+     */
94
+    public function create($name, $pattern, array $defaults = [], array $requirements = []);
95 95
 
96
-	/**
97
-	 * Find the route matching $url.
98
-	 *
99
-	 * @param string $url The url to find
100
-	 * @throws \Exception
101
-	 * @return void
102
-	 * @since 7.0.0
103
-	 * @deprecated 9.0.0
104
-	 */
105
-	public function match($url);
96
+    /**
97
+     * Find the route matching $url.
98
+     *
99
+     * @param string $url The url to find
100
+     * @throws \Exception
101
+     * @return void
102
+     * @since 7.0.0
103
+     * @deprecated 9.0.0
104
+     */
105
+    public function match($url);
106 106
 
107
-	/**
108
-	 * Get the url generator
109
-	 *
110
-	 * @since 7.0.0
111
-	 * @deprecated 9.0.0
112
-	 */
113
-	public function getGenerator();
107
+    /**
108
+     * Get the url generator
109
+     *
110
+     * @since 7.0.0
111
+     * @deprecated 9.0.0
112
+     */
113
+    public function getGenerator();
114 114
 
115
-	/**
116
-	 * Generate url based on $name and $parameters
117
-	 *
118
-	 * @param string $name Name of the route to use.
119
-	 * @param array $parameters Parameters for the route
120
-	 * @param bool $absolute
121
-	 * @return string
122
-	 * @since 7.0.0
123
-	 * @deprecated 9.0.0
124
-	 */
125
-	public function generate($name, $parameters = [], $absolute = false);
115
+    /**
116
+     * Generate url based on $name and $parameters
117
+     *
118
+     * @param string $name Name of the route to use.
119
+     * @param array $parameters Parameters for the route
120
+     * @param bool $absolute
121
+     * @return string
122
+     * @since 7.0.0
123
+     * @deprecated 9.0.0
124
+     */
125
+    public function generate($name, $parameters = [], $absolute = false);
126 126
 }
Please login to merge, or discard this patch.
lib/public/DB/QueryBuilder/ICompositeExpression.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -28,39 +28,39 @@
 block discarded – undo
28 28
  * @since 8.2.0
29 29
  */
30 30
 interface ICompositeExpression {
31
-	/**
32
-	 * Adds multiple parts to composite expression.
33
-	 *
34
-	 * @param array $parts
35
-	 *
36
-	 * @return ICompositeExpression
37
-	 * @since 8.2.0
38
-	 */
39
-	public function addMultiple(array $parts = []);
31
+    /**
32
+     * Adds multiple parts to composite expression.
33
+     *
34
+     * @param array $parts
35
+     *
36
+     * @return ICompositeExpression
37
+     * @since 8.2.0
38
+     */
39
+    public function addMultiple(array $parts = []);
40 40
 
41
-	/**
42
-	 * Adds an expression to composite expression.
43
-	 *
44
-	 * @param mixed $part
45
-	 *
46
-	 * @return ICompositeExpression
47
-	 * @since 8.2.0
48
-	 */
49
-	public function add($part);
41
+    /**
42
+     * Adds an expression to composite expression.
43
+     *
44
+     * @param mixed $part
45
+     *
46
+     * @return ICompositeExpression
47
+     * @since 8.2.0
48
+     */
49
+    public function add($part);
50 50
 
51
-	/**
52
-	 * Retrieves the amount of expressions on composite expression.
53
-	 *
54
-	 * @return integer
55
-	 * @since 8.2.0
56
-	 */
57
-	public function count();
51
+    /**
52
+     * Retrieves the amount of expressions on composite expression.
53
+     *
54
+     * @return integer
55
+     * @since 8.2.0
56
+     */
57
+    public function count();
58 58
 
59
-	/**
60
-	 * Returns the type of this composite expression (AND/OR).
61
-	 *
62
-	 * @return string
63
-	 * @since 8.2.0
64
-	 */
65
-	public function getType();
59
+    /**
60
+     * Returns the type of this composite expression (AND/OR).
61
+     *
62
+     * @return string
63
+     * @since 8.2.0
64
+     */
65
+    public function getType();
66 66
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Controller.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// default responders
80 80
 		$this->responders = [
81
-			'json' => function ($data) {
81
+			'json' => function($data) {
82 82
 				if ($data instanceof DataResponse) {
83 83
 					$response = new JSONResponse(
84 84
 						$data->getData(),
@@ -153,6 +153,6 @@  discard block
 block discarded – undo
153 153
 			return $responder($response);
154 154
 		}
155 155
 		throw new \DomainException('No responder registered for format '.
156
-			$format . '!');
156
+			$format.'!');
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -45,122 +45,122 @@
 block discarded – undo
45 45
  */
46 46
 abstract class Controller {
47 47
 
48
-	/**
49
-	 * app name
50
-	 * @var string
51
-	 * @since 7.0.0
52
-	 */
53
-	protected $appName;
54
-
55
-	/**
56
-	 * current request
57
-	 * @var \OCP\IRequest
58
-	 * @since 6.0.0
59
-	 */
60
-	protected $request;
61
-
62
-	/**
63
-	 * @var array
64
-	 * @since 7.0.0
65
-	 */
66
-	private $responders;
67
-
68
-	/**
69
-	 * constructor of the controller
70
-	 * @param string $appName the name of the app
71
-	 * @param IRequest $request an instance of the request
72
-	 * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
73
-	 */
74
-	public function __construct($appName,
75
-								IRequest $request) {
76
-		$this->appName = $appName;
77
-		$this->request = $request;
78
-
79
-		// default responders
80
-		$this->responders = [
81
-			'json' => function ($data) {
82
-				if ($data instanceof DataResponse) {
83
-					$response = new JSONResponse(
84
-						$data->getData(),
85
-						$data->getStatus()
86
-					);
87
-					$dataHeaders = $data->getHeaders();
88
-					$headers = $response->getHeaders();
89
-					// do not overwrite Content-Type if it already exists
90
-					if (isset($dataHeaders['Content-Type'])) {
91
-						unset($headers['Content-Type']);
92
-					}
93
-					$response->setHeaders(array_merge($dataHeaders, $headers));
94
-
95
-					if ($data->getETag() !== null) {
96
-						$response->setETag($data->getETag());
97
-					}
98
-					if ($data->getLastModified() !== null) {
99
-						$response->setLastModified($data->getLastModified());
100
-					}
101
-
102
-					return $response;
103
-				}
104
-				return new JSONResponse($data);
105
-			}
106
-		];
107
-	}
108
-
109
-
110
-	/**
111
-	 * Parses an HTTP accept header and returns the supported responder type
112
-	 * @param string $acceptHeader
113
-	 * @param string $default
114
-	 * @return string the responder type
115
-	 * @since 7.0.0
116
-	 * @since 9.1.0 Added default parameter
117
-	 */
118
-	public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
119
-		$headers = explode(',', $acceptHeader);
120
-
121
-		// return the first matching responder
122
-		foreach ($headers as $header) {
123
-			$header = strtolower(trim($header));
124
-
125
-			$responder = str_replace('application/', '', $header);
126
-
127
-			if (array_key_exists($responder, $this->responders)) {
128
-				return $responder;
129
-			}
130
-		}
131
-
132
-		// no matching header return default
133
-		return $default;
134
-	}
135
-
136
-
137
-	/**
138
-	 * Registers a formatter for a type
139
-	 * @param string $format
140
-	 * @param \Closure $responder
141
-	 * @since 7.0.0
142
-	 */
143
-	protected function registerResponder($format, \Closure $responder) {
144
-		$this->responders[$format] = $responder;
145
-	}
146
-
147
-
148
-	/**
149
-	 * Serializes and formats a response
150
-	 * @param mixed $response the value that was returned from a controller and
151
-	 * is not a Response instance
152
-	 * @param string $format the format for which a formatter has been registered
153
-	 * @throws \DomainException if format does not match a registered formatter
154
-	 * @return Response
155
-	 * @since 7.0.0
156
-	 */
157
-	public function buildResponse($response, $format = 'json') {
158
-		if (array_key_exists($format, $this->responders)) {
159
-			$responder = $this->responders[$format];
160
-
161
-			return $responder($response);
162
-		}
163
-		throw new \DomainException('No responder registered for format '.
164
-			$format . '!');
165
-	}
48
+    /**
49
+     * app name
50
+     * @var string
51
+     * @since 7.0.0
52
+     */
53
+    protected $appName;
54
+
55
+    /**
56
+     * current request
57
+     * @var \OCP\IRequest
58
+     * @since 6.0.0
59
+     */
60
+    protected $request;
61
+
62
+    /**
63
+     * @var array
64
+     * @since 7.0.0
65
+     */
66
+    private $responders;
67
+
68
+    /**
69
+     * constructor of the controller
70
+     * @param string $appName the name of the app
71
+     * @param IRequest $request an instance of the request
72
+     * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
73
+     */
74
+    public function __construct($appName,
75
+                                IRequest $request) {
76
+        $this->appName = $appName;
77
+        $this->request = $request;
78
+
79
+        // default responders
80
+        $this->responders = [
81
+            'json' => function ($data) {
82
+                if ($data instanceof DataResponse) {
83
+                    $response = new JSONResponse(
84
+                        $data->getData(),
85
+                        $data->getStatus()
86
+                    );
87
+                    $dataHeaders = $data->getHeaders();
88
+                    $headers = $response->getHeaders();
89
+                    // do not overwrite Content-Type if it already exists
90
+                    if (isset($dataHeaders['Content-Type'])) {
91
+                        unset($headers['Content-Type']);
92
+                    }
93
+                    $response->setHeaders(array_merge($dataHeaders, $headers));
94
+
95
+                    if ($data->getETag() !== null) {
96
+                        $response->setETag($data->getETag());
97
+                    }
98
+                    if ($data->getLastModified() !== null) {
99
+                        $response->setLastModified($data->getLastModified());
100
+                    }
101
+
102
+                    return $response;
103
+                }
104
+                return new JSONResponse($data);
105
+            }
106
+        ];
107
+    }
108
+
109
+
110
+    /**
111
+     * Parses an HTTP accept header and returns the supported responder type
112
+     * @param string $acceptHeader
113
+     * @param string $default
114
+     * @return string the responder type
115
+     * @since 7.0.0
116
+     * @since 9.1.0 Added default parameter
117
+     */
118
+    public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
119
+        $headers = explode(',', $acceptHeader);
120
+
121
+        // return the first matching responder
122
+        foreach ($headers as $header) {
123
+            $header = strtolower(trim($header));
124
+
125
+            $responder = str_replace('application/', '', $header);
126
+
127
+            if (array_key_exists($responder, $this->responders)) {
128
+                return $responder;
129
+            }
130
+        }
131
+
132
+        // no matching header return default
133
+        return $default;
134
+    }
135
+
136
+
137
+    /**
138
+     * Registers a formatter for a type
139
+     * @param string $format
140
+     * @param \Closure $responder
141
+     * @since 7.0.0
142
+     */
143
+    protected function registerResponder($format, \Closure $responder) {
144
+        $this->responders[$format] = $responder;
145
+    }
146
+
147
+
148
+    /**
149
+     * Serializes and formats a response
150
+     * @param mixed $response the value that was returned from a controller and
151
+     * is not a Response instance
152
+     * @param string $format the format for which a formatter has been registered
153
+     * @throws \DomainException if format does not match a registered formatter
154
+     * @return Response
155
+     * @since 7.0.0
156
+     */
157
+    public function buildResponse($response, $format = 'json') {
158
+        if (array_key_exists($format, $this->responders)) {
159
+            $responder = $this->responders[$format];
160
+
161
+            return $responder($response);
162
+        }
163
+        throw new \DomainException('No responder registered for format '.
164
+            $format . '!');
165
+    }
166 166
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Middleware.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -42,67 +42,67 @@
 block discarded – undo
42 42
 abstract class Middleware {
43 43
 
44 44
 
45
-	/**
46
-	 * This is being run in normal order before the controller is being
47
-	 * called which allows several modifications and checks
48
-	 *
49
-	 * @param Controller $controller the controller that is being called
50
-	 * @param string $methodName the name of the method that will be called on
51
-	 *                           the controller
52
-	 * @since 6.0.0
53
-	 */
54
-	public function beforeController($controller, $methodName) {
55
-	}
45
+    /**
46
+     * This is being run in normal order before the controller is being
47
+     * called which allows several modifications and checks
48
+     *
49
+     * @param Controller $controller the controller that is being called
50
+     * @param string $methodName the name of the method that will be called on
51
+     *                           the controller
52
+     * @since 6.0.0
53
+     */
54
+    public function beforeController($controller, $methodName) {
55
+    }
56 56
 
57 57
 
58
-	/**
59
-	 * This is being run when either the beforeController method or the
60
-	 * controller method itself is throwing an exception. The middleware is
61
-	 * asked in reverse order to handle the exception and to return a response.
62
-	 * If the response is null, it is assumed that the exception could not be
63
-	 * handled and the error will be thrown again
64
-	 *
65
-	 * @param Controller $controller the controller that is being called
66
-	 * @param string $methodName the name of the method that will be called on
67
-	 *                           the controller
68
-	 * @param \Exception $exception the thrown exception
69
-	 * @throws \Exception the passed in exception if it can't handle it
70
-	 * @return Response a Response object in case that the exception was handled
71
-	 * @since 6.0.0
72
-	 */
73
-	public function afterException($controller, $methodName, \Exception $exception) {
74
-		throw $exception;
75
-	}
58
+    /**
59
+     * This is being run when either the beforeController method or the
60
+     * controller method itself is throwing an exception. The middleware is
61
+     * asked in reverse order to handle the exception and to return a response.
62
+     * If the response is null, it is assumed that the exception could not be
63
+     * handled and the error will be thrown again
64
+     *
65
+     * @param Controller $controller the controller that is being called
66
+     * @param string $methodName the name of the method that will be called on
67
+     *                           the controller
68
+     * @param \Exception $exception the thrown exception
69
+     * @throws \Exception the passed in exception if it can't handle it
70
+     * @return Response a Response object in case that the exception was handled
71
+     * @since 6.0.0
72
+     */
73
+    public function afterException($controller, $methodName, \Exception $exception) {
74
+        throw $exception;
75
+    }
76 76
 
77 77
 
78
-	/**
79
-	 * This is being run after a successful controllermethod call and allows
80
-	 * the manipulation of a Response object. The middleware is run in reverse order
81
-	 *
82
-	 * @param Controller $controller the controller that is being called
83
-	 * @param string $methodName the name of the method that will be called on
84
-	 *                           the controller
85
-	 * @param Response $response the generated response from the controller
86
-	 * @return Response a Response object
87
-	 * @since 6.0.0
88
-	 */
89
-	public function afterController($controller, $methodName, Response $response) {
90
-		return $response;
91
-	}
78
+    /**
79
+     * This is being run after a successful controllermethod call and allows
80
+     * the manipulation of a Response object. The middleware is run in reverse order
81
+     *
82
+     * @param Controller $controller the controller that is being called
83
+     * @param string $methodName the name of the method that will be called on
84
+     *                           the controller
85
+     * @param Response $response the generated response from the controller
86
+     * @return Response a Response object
87
+     * @since 6.0.0
88
+     */
89
+    public function afterController($controller, $methodName, Response $response) {
90
+        return $response;
91
+    }
92 92
 
93 93
 
94
-	/**
95
-	 * This is being run after the response object has been rendered and
96
-	 * allows the manipulation of the output. The middleware is run in reverse order
97
-	 *
98
-	 * @param Controller $controller the controller that is being called
99
-	 * @param string $methodName the name of the method that will be called on
100
-	 *                           the controller
101
-	 * @param string $output the generated output from a response
102
-	 * @return string the output that should be printed
103
-	 * @since 6.0.0
104
-	 */
105
-	public function beforeOutput($controller, $methodName, $output) {
106
-		return $output;
107
-	}
94
+    /**
95
+     * This is being run after the response object has been rendered and
96
+     * allows the manipulation of the output. The middleware is run in reverse order
97
+     *
98
+     * @param Controller $controller the controller that is being called
99
+     * @param string $methodName the name of the method that will be called on
100
+     *                           the controller
101
+     * @param string $output the generated output from a response
102
+     * @return string the output that should be printed
103
+     * @since 6.0.0
104
+     */
105
+    public function beforeOutput($controller, $methodName, $output) {
106
+        return $output;
107
+    }
108 108
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSNotFoundException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSNotFoundException extends OCSException {
35
-	/**
36
-	 * OCSNotFoundException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
-	}
35
+    /**
36
+     * OCSNotFoundException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.