Passed
Push — master ( 17be48...2e8209 )
by Jan-Christoph
26:34 queued 14:54
created
lib/private/AppConfig.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@
 block discarded – undo
275 275
 			return $this->getAppValues($app);
276 276
 		} else {
277 277
 			$appIds = $this->getApps();
278
-			$values = array_map(function ($appId) use ($key) {
278
+			$values = array_map(function($appId) use ($key) {
279 279
 				return isset($this->cache[$appId][$key]) ? $this->cache[$appId][$key] : null;
280 280
 			}, $appIds);
281 281
 			$result = array_combine($appIds, $values);
Please login to merge, or discard this patch.
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -43,305 +43,305 @@
 block discarded – undo
43 43
  */
44 44
 class AppConfig implements IAppConfig {
45 45
 
46
-	/** @var array[] */
47
-	protected $sensitiveValues = [
48
-		'external' => [
49
-			'/^sites$/',
50
-		],
51
-		'spreed' => [
52
-			'/^bridge_bot_password/',
53
-			'/^signaling_servers$/',
54
-			'/^signaling_ticket_secret$/',
55
-			'/^stun_servers$/',
56
-			'/^turn_servers$/',
57
-			'/^turn_server_secret$/',
58
-		],
59
-		'theming' => [
60
-			'/^imprintUrl$/',
61
-			'/^privacyUrl$/',
62
-			'/^slogan$/',
63
-			'/^url$/',
64
-		],
65
-		'user_ldap' => [
66
-			'/^(s..)?ldap_agent_password$/',
67
-		],
68
-	];
69
-
70
-	/** @var \OCP\IDBConnection */
71
-	protected $conn;
72
-
73
-	/** @var array[] */
74
-	private $cache = [];
75
-
76
-	/** @var bool */
77
-	private $configLoaded = false;
78
-
79
-	/**
80
-	 * @param IDBConnection $conn
81
-	 */
82
-	public function __construct(IDBConnection $conn) {
83
-		$this->conn = $conn;
84
-		$this->configLoaded = false;
85
-	}
86
-
87
-	/**
88
-	 * @param string $app
89
-	 * @return array
90
-	 */
91
-	private function getAppValues($app) {
92
-		$this->loadConfigValues();
93
-
94
-		if (isset($this->cache[$app])) {
95
-			return $this->cache[$app];
96
-		}
97
-
98
-		return [];
99
-	}
100
-
101
-	/**
102
-	 * Get all apps using the config
103
-	 *
104
-	 * @return array an array of app ids
105
-	 *
106
-	 * This function returns a list of all apps that have at least one
107
-	 * entry in the appconfig table.
108
-	 */
109
-	public function getApps() {
110
-		$this->loadConfigValues();
111
-
112
-		return $this->getSortedKeys($this->cache);
113
-	}
114
-
115
-	/**
116
-	 * Get the available keys for an app
117
-	 *
118
-	 * @param string $app the app we are looking for
119
-	 * @return array an array of key names
120
-	 *
121
-	 * This function gets all keys of an app. Please note that the values are
122
-	 * not returned.
123
-	 */
124
-	public function getKeys($app) {
125
-		$this->loadConfigValues();
126
-
127
-		if (isset($this->cache[$app])) {
128
-			return $this->getSortedKeys($this->cache[$app]);
129
-		}
130
-
131
-		return [];
132
-	}
133
-
134
-	public function getSortedKeys($data) {
135
-		$keys = array_keys($data);
136
-		sort($keys);
137
-		return $keys;
138
-	}
139
-
140
-	/**
141
-	 * Gets the config value
142
-	 *
143
-	 * @param string $app app
144
-	 * @param string $key key
145
-	 * @param string $default = null, default value if the key does not exist
146
-	 * @return string the value or $default
147
-	 *
148
-	 * This function gets a value from the appconfig table. If the key does
149
-	 * not exist the default value will be returned
150
-	 */
151
-	public function getValue($app, $key, $default = null) {
152
-		$this->loadConfigValues();
153
-
154
-		if ($this->hasKey($app, $key)) {
155
-			return $this->cache[$app][$key];
156
-		}
157
-
158
-		return $default;
159
-	}
160
-
161
-	/**
162
-	 * check if a key is set in the appconfig
163
-	 *
164
-	 * @param string $app
165
-	 * @param string $key
166
-	 * @return bool
167
-	 */
168
-	public function hasKey($app, $key) {
169
-		$this->loadConfigValues();
170
-
171
-		return isset($this->cache[$app][$key]);
172
-	}
173
-
174
-	/**
175
-	 * Sets a value. If the key did not exist before it will be created.
176
-	 *
177
-	 * @param string $app app
178
-	 * @param string $key key
179
-	 * @param string|float|int $value value
180
-	 * @return bool True if the value was inserted or updated, false if the value was the same
181
-	 */
182
-	public function setValue($app, $key, $value) {
183
-		if (!$this->hasKey($app, $key)) {
184
-			$inserted = (bool) $this->conn->insertIfNotExist('*PREFIX*appconfig', [
185
-				'appid' => $app,
186
-				'configkey' => $key,
187
-				'configvalue' => $value,
188
-			], [
189
-				'appid',
190
-				'configkey',
191
-			]);
192
-
193
-			if ($inserted) {
194
-				if (!isset($this->cache[$app])) {
195
-					$this->cache[$app] = [];
196
-				}
197
-
198
-				$this->cache[$app][$key] = $value;
199
-				return true;
200
-			}
201
-		}
202
-
203
-		$sql = $this->conn->getQueryBuilder();
204
-		$sql->update('appconfig')
205
-			->set('configvalue', $sql->createParameter('configvalue'))
206
-			->where($sql->expr()->eq('appid', $sql->createParameter('app')))
207
-			->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
208
-			->setParameter('configvalue', $value)
209
-			->setParameter('app', $app)
210
-			->setParameter('configkey', $key);
211
-
212
-		/*
46
+    /** @var array[] */
47
+    protected $sensitiveValues = [
48
+        'external' => [
49
+            '/^sites$/',
50
+        ],
51
+        'spreed' => [
52
+            '/^bridge_bot_password/',
53
+            '/^signaling_servers$/',
54
+            '/^signaling_ticket_secret$/',
55
+            '/^stun_servers$/',
56
+            '/^turn_servers$/',
57
+            '/^turn_server_secret$/',
58
+        ],
59
+        'theming' => [
60
+            '/^imprintUrl$/',
61
+            '/^privacyUrl$/',
62
+            '/^slogan$/',
63
+            '/^url$/',
64
+        ],
65
+        'user_ldap' => [
66
+            '/^(s..)?ldap_agent_password$/',
67
+        ],
68
+    ];
69
+
70
+    /** @var \OCP\IDBConnection */
71
+    protected $conn;
72
+
73
+    /** @var array[] */
74
+    private $cache = [];
75
+
76
+    /** @var bool */
77
+    private $configLoaded = false;
78
+
79
+    /**
80
+     * @param IDBConnection $conn
81
+     */
82
+    public function __construct(IDBConnection $conn) {
83
+        $this->conn = $conn;
84
+        $this->configLoaded = false;
85
+    }
86
+
87
+    /**
88
+     * @param string $app
89
+     * @return array
90
+     */
91
+    private function getAppValues($app) {
92
+        $this->loadConfigValues();
93
+
94
+        if (isset($this->cache[$app])) {
95
+            return $this->cache[$app];
96
+        }
97
+
98
+        return [];
99
+    }
100
+
101
+    /**
102
+     * Get all apps using the config
103
+     *
104
+     * @return array an array of app ids
105
+     *
106
+     * This function returns a list of all apps that have at least one
107
+     * entry in the appconfig table.
108
+     */
109
+    public function getApps() {
110
+        $this->loadConfigValues();
111
+
112
+        return $this->getSortedKeys($this->cache);
113
+    }
114
+
115
+    /**
116
+     * Get the available keys for an app
117
+     *
118
+     * @param string $app the app we are looking for
119
+     * @return array an array of key names
120
+     *
121
+     * This function gets all keys of an app. Please note that the values are
122
+     * not returned.
123
+     */
124
+    public function getKeys($app) {
125
+        $this->loadConfigValues();
126
+
127
+        if (isset($this->cache[$app])) {
128
+            return $this->getSortedKeys($this->cache[$app]);
129
+        }
130
+
131
+        return [];
132
+    }
133
+
134
+    public function getSortedKeys($data) {
135
+        $keys = array_keys($data);
136
+        sort($keys);
137
+        return $keys;
138
+    }
139
+
140
+    /**
141
+     * Gets the config value
142
+     *
143
+     * @param string $app app
144
+     * @param string $key key
145
+     * @param string $default = null, default value if the key does not exist
146
+     * @return string the value or $default
147
+     *
148
+     * This function gets a value from the appconfig table. If the key does
149
+     * not exist the default value will be returned
150
+     */
151
+    public function getValue($app, $key, $default = null) {
152
+        $this->loadConfigValues();
153
+
154
+        if ($this->hasKey($app, $key)) {
155
+            return $this->cache[$app][$key];
156
+        }
157
+
158
+        return $default;
159
+    }
160
+
161
+    /**
162
+     * check if a key is set in the appconfig
163
+     *
164
+     * @param string $app
165
+     * @param string $key
166
+     * @return bool
167
+     */
168
+    public function hasKey($app, $key) {
169
+        $this->loadConfigValues();
170
+
171
+        return isset($this->cache[$app][$key]);
172
+    }
173
+
174
+    /**
175
+     * Sets a value. If the key did not exist before it will be created.
176
+     *
177
+     * @param string $app app
178
+     * @param string $key key
179
+     * @param string|float|int $value value
180
+     * @return bool True if the value was inserted or updated, false if the value was the same
181
+     */
182
+    public function setValue($app, $key, $value) {
183
+        if (!$this->hasKey($app, $key)) {
184
+            $inserted = (bool) $this->conn->insertIfNotExist('*PREFIX*appconfig', [
185
+                'appid' => $app,
186
+                'configkey' => $key,
187
+                'configvalue' => $value,
188
+            ], [
189
+                'appid',
190
+                'configkey',
191
+            ]);
192
+
193
+            if ($inserted) {
194
+                if (!isset($this->cache[$app])) {
195
+                    $this->cache[$app] = [];
196
+                }
197
+
198
+                $this->cache[$app][$key] = $value;
199
+                return true;
200
+            }
201
+        }
202
+
203
+        $sql = $this->conn->getQueryBuilder();
204
+        $sql->update('appconfig')
205
+            ->set('configvalue', $sql->createParameter('configvalue'))
206
+            ->where($sql->expr()->eq('appid', $sql->createParameter('app')))
207
+            ->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
208
+            ->setParameter('configvalue', $value)
209
+            ->setParameter('app', $app)
210
+            ->setParameter('configkey', $key);
211
+
212
+        /*
213 213
 		 * Only limit to the existing value for non-Oracle DBs:
214 214
 		 * http://docs.oracle.com/cd/E11882_01/server.112/e26088/conditions002.htm#i1033286
215 215
 		 * > Large objects (LOBs) are not supported in comparison conditions.
216 216
 		 */
217
-		if (!($this->conn instanceof OracleConnection)) {
218
-			// Only update the value when it is not the same
219
-			$sql->andWhere($sql->expr()->neq('configvalue', $sql->createParameter('configvalue')))
220
-				->setParameter('configvalue', $value);
221
-		}
222
-
223
-		$changedRow = (bool) $sql->execute();
224
-
225
-		$this->cache[$app][$key] = $value;
226
-
227
-		return $changedRow;
228
-	}
229
-
230
-	/**
231
-	 * Deletes a key
232
-	 *
233
-	 * @param string $app app
234
-	 * @param string $key key
235
-	 * @return boolean
236
-	 */
237
-	public function deleteKey($app, $key) {
238
-		$this->loadConfigValues();
239
-
240
-		$sql = $this->conn->getQueryBuilder();
241
-		$sql->delete('appconfig')
242
-			->where($sql->expr()->eq('appid', $sql->createParameter('app')))
243
-			->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
244
-			->setParameter('app', $app)
245
-			->setParameter('configkey', $key);
246
-		$sql->execute();
247
-
248
-		unset($this->cache[$app][$key]);
249
-		return false;
250
-	}
251
-
252
-	/**
253
-	 * Remove app from appconfig
254
-	 *
255
-	 * @param string $app app
256
-	 * @return boolean
257
-	 *
258
-	 * Removes all keys in appconfig belonging to the app.
259
-	 */
260
-	public function deleteApp($app) {
261
-		$this->loadConfigValues();
262
-
263
-		$sql = $this->conn->getQueryBuilder();
264
-		$sql->delete('appconfig')
265
-			->where($sql->expr()->eq('appid', $sql->createParameter('app')))
266
-			->setParameter('app', $app);
267
-		$sql->execute();
268
-
269
-		unset($this->cache[$app]);
270
-		return false;
271
-	}
272
-
273
-	/**
274
-	 * get multiple values, either the app or key can be used as wildcard by setting it to false
275
-	 *
276
-	 * @param string|false $app
277
-	 * @param string|false $key
278
-	 * @return array|false
279
-	 */
280
-	public function getValues($app, $key) {
281
-		if (($app !== false) === ($key !== false)) {
282
-			return false;
283
-		}
284
-
285
-		if ($key === false) {
286
-			return $this->getAppValues($app);
287
-		} else {
288
-			$appIds = $this->getApps();
289
-			$values = array_map(function ($appId) use ($key) {
290
-				return isset($this->cache[$appId][$key]) ? $this->cache[$appId][$key] : null;
291
-			}, $appIds);
292
-			$result = array_combine($appIds, $values);
293
-
294
-			return array_filter($result);
295
-		}
296
-	}
297
-
298
-	/**
299
-	 * get all values of the app or and filters out sensitive data
300
-	 *
301
-	 * @param string $app
302
-	 * @return array
303
-	 */
304
-	public function getFilteredValues($app) {
305
-		$values = $this->getValues($app, false);
306
-
307
-		if (isset($this->sensitiveValues[$app])) {
308
-			foreach ($this->sensitiveValues[$app] as $sensitiveKeyExp) {
309
-				$sensitiveKeys = preg_grep($sensitiveKeyExp, array_keys($values));
310
-				foreach ($sensitiveKeys as $sensitiveKey) {
311
-					$values[$sensitiveKey] = IConfig::SENSITIVE_VALUE;
312
-				}
313
-			}
314
-		}
315
-
316
-		return $values;
317
-	}
318
-
319
-	/**
320
-	 * Load all the app config values
321
-	 */
322
-	protected function loadConfigValues() {
323
-		if ($this->configLoaded) {
324
-			return;
325
-		}
326
-
327
-		$this->cache = [];
328
-
329
-		$sql = $this->conn->getQueryBuilder();
330
-		$sql->select('*')
331
-			->from('appconfig');
332
-		$result = $sql->execute();
333
-
334
-		// we are going to store the result in memory anyway
335
-		$rows = $result->fetchAll();
336
-		foreach ($rows as $row) {
337
-			if (!isset($this->cache[$row['appid']])) {
338
-				$this->cache[$row['appid']] = [];
339
-			}
340
-
341
-			$this->cache[$row['appid']][$row['configkey']] = $row['configvalue'];
342
-		}
343
-		$result->closeCursor();
344
-
345
-		$this->configLoaded = true;
346
-	}
217
+        if (!($this->conn instanceof OracleConnection)) {
218
+            // Only update the value when it is not the same
219
+            $sql->andWhere($sql->expr()->neq('configvalue', $sql->createParameter('configvalue')))
220
+                ->setParameter('configvalue', $value);
221
+        }
222
+
223
+        $changedRow = (bool) $sql->execute();
224
+
225
+        $this->cache[$app][$key] = $value;
226
+
227
+        return $changedRow;
228
+    }
229
+
230
+    /**
231
+     * Deletes a key
232
+     *
233
+     * @param string $app app
234
+     * @param string $key key
235
+     * @return boolean
236
+     */
237
+    public function deleteKey($app, $key) {
238
+        $this->loadConfigValues();
239
+
240
+        $sql = $this->conn->getQueryBuilder();
241
+        $sql->delete('appconfig')
242
+            ->where($sql->expr()->eq('appid', $sql->createParameter('app')))
243
+            ->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
244
+            ->setParameter('app', $app)
245
+            ->setParameter('configkey', $key);
246
+        $sql->execute();
247
+
248
+        unset($this->cache[$app][$key]);
249
+        return false;
250
+    }
251
+
252
+    /**
253
+     * Remove app from appconfig
254
+     *
255
+     * @param string $app app
256
+     * @return boolean
257
+     *
258
+     * Removes all keys in appconfig belonging to the app.
259
+     */
260
+    public function deleteApp($app) {
261
+        $this->loadConfigValues();
262
+
263
+        $sql = $this->conn->getQueryBuilder();
264
+        $sql->delete('appconfig')
265
+            ->where($sql->expr()->eq('appid', $sql->createParameter('app')))
266
+            ->setParameter('app', $app);
267
+        $sql->execute();
268
+
269
+        unset($this->cache[$app]);
270
+        return false;
271
+    }
272
+
273
+    /**
274
+     * get multiple values, either the app or key can be used as wildcard by setting it to false
275
+     *
276
+     * @param string|false $app
277
+     * @param string|false $key
278
+     * @return array|false
279
+     */
280
+    public function getValues($app, $key) {
281
+        if (($app !== false) === ($key !== false)) {
282
+            return false;
283
+        }
284
+
285
+        if ($key === false) {
286
+            return $this->getAppValues($app);
287
+        } else {
288
+            $appIds = $this->getApps();
289
+            $values = array_map(function ($appId) use ($key) {
290
+                return isset($this->cache[$appId][$key]) ? $this->cache[$appId][$key] : null;
291
+            }, $appIds);
292
+            $result = array_combine($appIds, $values);
293
+
294
+            return array_filter($result);
295
+        }
296
+    }
297
+
298
+    /**
299
+     * get all values of the app or and filters out sensitive data
300
+     *
301
+     * @param string $app
302
+     * @return array
303
+     */
304
+    public function getFilteredValues($app) {
305
+        $values = $this->getValues($app, false);
306
+
307
+        if (isset($this->sensitiveValues[$app])) {
308
+            foreach ($this->sensitiveValues[$app] as $sensitiveKeyExp) {
309
+                $sensitiveKeys = preg_grep($sensitiveKeyExp, array_keys($values));
310
+                foreach ($sensitiveKeys as $sensitiveKey) {
311
+                    $values[$sensitiveKey] = IConfig::SENSITIVE_VALUE;
312
+                }
313
+            }
314
+        }
315
+
316
+        return $values;
317
+    }
318
+
319
+    /**
320
+     * Load all the app config values
321
+     */
322
+    protected function loadConfigValues() {
323
+        if ($this->configLoaded) {
324
+            return;
325
+        }
326
+
327
+        $this->cache = [];
328
+
329
+        $sql = $this->conn->getQueryBuilder();
330
+        $sql->select('*')
331
+            ->from('appconfig');
332
+        $result = $sql->execute();
333
+
334
+        // we are going to store the result in memory anyway
335
+        $rows = $result->fetchAll();
336
+        foreach ($rows as $row) {
337
+            if (!isset($this->cache[$row['appid']])) {
338
+                $this->cache[$row['appid']] = [];
339
+            }
340
+
341
+            $this->cache[$row['appid']][$row['configkey']] = $row['configvalue'];
342
+        }
343
+        $result->closeCursor();
344
+
345
+        $this->configLoaded = true;
346
+    }
347 347
 }
Please login to merge, or discard this patch.
lib/private/Repair/MoveUpdaterStepFile.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -28,51 +28,51 @@
 block discarded – undo
28 28
 
29 29
 class MoveUpdaterStepFile implements IRepairStep {
30 30
 
31
-	/** @var \OCP\IConfig */
32
-	protected $config;
31
+    /** @var \OCP\IConfig */
32
+    protected $config;
33 33
 
34
-	/**
35
-	 * @param \OCP\IConfig $config
36
-	 */
37
-	public function __construct($config) {
38
-		$this->config = $config;
39
-	}
34
+    /**
35
+     * @param \OCP\IConfig $config
36
+     */
37
+    public function __construct($config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	public function getName() {
42
-		return 'Move .step file of updater to backup location';
43
-	}
41
+    public function getName() {
42
+        return 'Move .step file of updater to backup location';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
46
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
47
-		$instanceId = $this->config->getSystemValue('instanceid', null);
45
+    public function run(IOutput $output) {
46
+        $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
47
+        $instanceId = $this->config->getSystemValue('instanceid', null);
48 48
 
49
-		if (!is_string($instanceId) || empty($instanceId)) {
50
-			return;
51
-		}
49
+        if (!is_string($instanceId) || empty($instanceId)) {
50
+            return;
51
+        }
52 52
 
53
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
54
-		$stepFile = $updaterFolderPath . '/.step';
55
-		if (file_exists($stepFile)) {
56
-			$output->info('.step file exists');
53
+        $updaterFolderPath = $dataDir . '/updater-' . $instanceId;
54
+        $stepFile = $updaterFolderPath . '/.step';
55
+        if (file_exists($stepFile)) {
56
+            $output->info('.step file exists');
57 57
 
58
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
58
+            $previousStepFile = $updaterFolderPath . '/.step-previous-update';
59 59
 
60
-			// cleanup
61
-			if (file_exists($previousStepFile)) {
62
-				if (\OC_Helper::rmdirr($previousStepFile)) {
63
-					$output->info('.step-previous-update removed');
64
-				} else {
65
-					$output->info('.step-previous-update can\'t be removed - abort move of .step file');
66
-					return;
67
-				}
68
-			}
60
+            // cleanup
61
+            if (file_exists($previousStepFile)) {
62
+                if (\OC_Helper::rmdirr($previousStepFile)) {
63
+                    $output->info('.step-previous-update removed');
64
+                } else {
65
+                    $output->info('.step-previous-update can\'t be removed - abort move of .step file');
66
+                    return;
67
+                }
68
+            }
69 69
 
70
-			// move step file
71
-			if (rename($stepFile, $previousStepFile)) {
72
-				$output->info('.step file moved to .step-previous-update');
73
-			} else {
74
-				$output->warning('.step file can\'t be moved');
75
-			}
76
-		}
77
-	}
70
+            // move step file
71
+            if (rename($stepFile, $previousStepFile)) {
72
+                $output->info('.step file moved to .step-previous-update');
73
+            } else {
74
+                $output->warning('.step file can\'t be moved');
75
+            }
76
+        }
77
+    }
78 78
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,19 +43,19 @@
 block discarded – undo
43 43
 	}
44 44
 
45 45
 	public function run(IOutput $output) {
46
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
46
+		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
47 47
 		$instanceId = $this->config->getSystemValue('instanceid', null);
48 48
 
49 49
 		if (!is_string($instanceId) || empty($instanceId)) {
50 50
 			return;
51 51
 		}
52 52
 
53
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
54
-		$stepFile = $updaterFolderPath . '/.step';
53
+		$updaterFolderPath = $dataDir.'/updater-'.$instanceId;
54
+		$stepFile = $updaterFolderPath.'/.step';
55 55
 		if (file_exists($stepFile)) {
56 56
 			$output->info('.step file exists');
57 57
 
58
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
58
+			$previousStepFile = $updaterFolderPath.'/.step-previous-update';
59 59
 
60 60
 			// cleanup
61 61
 			if (file_exists($previousStepFile)) {
Please login to merge, or discard this patch.
lib/private/Share/SearchResultSorter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 	public function sort($a, $b) {
54 54
 		if (!isset($a[$this->key]) || !isset($b[$this->key])) {
55 55
 			if (!is_null($this->log)) {
56
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
56
+				$this->log->error('Sharing dialogue: cannot sort due to '.
57 57
 								  'missing array key', ['app' => 'core']);
58 58
 			}
59 59
 			return 0;
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -29,50 +29,50 @@
 block discarded – undo
29 29
 use OCP\ILogger;
30 30
 
31 31
 class SearchResultSorter {
32
-	private $search;
33
-	private $encoding;
34
-	private $key;
35
-	private $log;
32
+    private $search;
33
+    private $encoding;
34
+    private $key;
35
+    private $log;
36 36
 
37
-	/**
38
-	 * @param string $search the search term as was given by the user
39
-	 * @param string $key the array key containing the value that should be compared
40
-	 * against
41
-	 * @param string $encoding optional, encoding to use, defaults to UTF-8
42
-	 * @param ILogger $log optional
43
-	 */
44
-	public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
45
-		$this->encoding = $encoding;
46
-		$this->key = $key;
47
-		$this->log = $log;
48
-		$this->search = mb_strtolower($search, $this->encoding);
49
-	}
37
+    /**
38
+     * @param string $search the search term as was given by the user
39
+     * @param string $key the array key containing the value that should be compared
40
+     * against
41
+     * @param string $encoding optional, encoding to use, defaults to UTF-8
42
+     * @param ILogger $log optional
43
+     */
44
+    public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
45
+        $this->encoding = $encoding;
46
+        $this->key = $key;
47
+        $this->log = $log;
48
+        $this->search = mb_strtolower($search, $this->encoding);
49
+    }
50 50
 
51
-	/**
52
-	 * User and Group names matching the search term at the beginning shall appear
53
-	 * on top of the share dialog. Following entries in alphabetical order.
54
-	 * Callback function for usort. http://php.net/usort
55
-	 */
56
-	public function sort($a, $b) {
57
-		if (!isset($a[$this->key]) || !isset($b[$this->key])) {
58
-			if (!is_null($this->log)) {
59
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
60
-								  'missing array key', ['app' => 'core']);
61
-			}
62
-			return 0;
63
-		}
64
-		$nameA = mb_strtolower($a[$this->key], $this->encoding);
65
-		$nameB = mb_strtolower($b[$this->key], $this->encoding);
66
-		$i = mb_strpos($nameA, $this->search, 0, $this->encoding);
67
-		$j = mb_strpos($nameB, $this->search, 0, $this->encoding);
51
+    /**
52
+     * User and Group names matching the search term at the beginning shall appear
53
+     * on top of the share dialog. Following entries in alphabetical order.
54
+     * Callback function for usort. http://php.net/usort
55
+     */
56
+    public function sort($a, $b) {
57
+        if (!isset($a[$this->key]) || !isset($b[$this->key])) {
58
+            if (!is_null($this->log)) {
59
+                $this->log->error('Sharing dialogue: cannot sort due to ' .
60
+                                    'missing array key', ['app' => 'core']);
61
+            }
62
+            return 0;
63
+        }
64
+        $nameA = mb_strtolower($a[$this->key], $this->encoding);
65
+        $nameB = mb_strtolower($b[$this->key], $this->encoding);
66
+        $i = mb_strpos($nameA, $this->search, 0, $this->encoding);
67
+        $j = mb_strpos($nameB, $this->search, 0, $this->encoding);
68 68
 
69
-		if ($i === $j || $i > 0 && $j > 0) {
70
-			return strcmp(mb_strtolower($nameA, $this->encoding),
71
-						  mb_strtolower($nameB, $this->encoding));
72
-		} elseif ($i === 0) {
73
-			return -1;
74
-		} else {
75
-			return 1;
76
-		}
77
-	}
69
+        if ($i === $j || $i > 0 && $j > 0) {
70
+            return strcmp(mb_strtolower($nameA, $this->encoding),
71
+                            mb_strtolower($nameB, $this->encoding));
72
+        } elseif ($i === 0) {
73
+            return -1;
74
+        } else {
75
+            return 1;
76
+        }
77
+    }
78 78
 }
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   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -36,58 +36,58 @@
 block discarded – undo
36 36
 
37 37
 class CapabilitiesManager {
38 38
 
39
-	/** @var \Closure[] */
40
-	private $capabilities = [];
39
+    /** @var \Closure[] */
40
+    private $capabilities = [];
41 41
 
42
-	/** @var ILogger */
43
-	private $logger;
42
+    /** @var ILogger */
43
+    private $logger;
44 44
 
45
-	public function __construct(ILogger $logger) {
46
-		$this->logger = $logger;
47
-	}
45
+    public function __construct(ILogger $logger) {
46
+        $this->logger = $logger;
47
+    }
48 48
 
49
-	/**
50
-	 * Get an array of al the capabilities that are registered at this manager
51
-	 *
52
-	 * @param bool $public get public capabilities only
53
-	 * @throws \InvalidArgumentException
54
-	 * @return array
55
-	 */
56
-	public function getCapabilities(bool $public = false) : array {
57
-		$capabilities = [];
58
-		foreach ($this->capabilities as $capability) {
59
-			try {
60
-				$c = $capability();
61
-			} catch (QueryException $e) {
62
-				$this->logger->logException($e, [
63
-					'message' => 'CapabilitiesManager',
64
-					'level' => ILogger::ERROR,
65
-					'app' => 'core',
66
-				]);
67
-				continue;
68
-			}
49
+    /**
50
+     * Get an array of al the capabilities that are registered at this manager
51
+     *
52
+     * @param bool $public get public capabilities only
53
+     * @throws \InvalidArgumentException
54
+     * @return array
55
+     */
56
+    public function getCapabilities(bool $public = false) : array {
57
+        $capabilities = [];
58
+        foreach ($this->capabilities as $capability) {
59
+            try {
60
+                $c = $capability();
61
+            } catch (QueryException $e) {
62
+                $this->logger->logException($e, [
63
+                    'message' => 'CapabilitiesManager',
64
+                    'level' => ILogger::ERROR,
65
+                    'app' => 'core',
66
+                ]);
67
+                continue;
68
+            }
69 69
 
70
-			if ($c instanceof ICapability) {
71
-				if (!$public || $c instanceof IPublicCapability) {
72
-					$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
73
-				}
74
-			} else {
75
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
76
-			}
77
-		}
70
+            if ($c instanceof ICapability) {
71
+                if (!$public || $c instanceof IPublicCapability) {
72
+                    $capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
73
+                }
74
+            } else {
75
+                throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
76
+            }
77
+        }
78 78
 
79
-		return $capabilities;
80
-	}
79
+        return $capabilities;
80
+    }
81 81
 
82
-	/**
83
-	 * In order to improve lazy loading a closure can be registered which will be called in case
84
-	 * capabilities are actually requested
85
-	 *
86
-	 * $callable has to return an instance of OCP\Capabilities\ICapability
87
-	 *
88
-	 * @param \Closure $callable
89
-	 */
90
-	public function registerCapability(\Closure $callable) {
91
-		$this->capabilities[] = $callable;
92
-	}
82
+    /**
83
+     * In order to improve lazy loading a closure can be registered which will be called in case
84
+     * capabilities are actually requested
85
+     *
86
+     * $callable has to return an instance of OCP\Capabilities\ICapability
87
+     *
88
+     * @param \Closure $callable
89
+     */
90
+    public function registerCapability(\Closure $callable) {
91
+        $this->capabilities[] = $callable;
92
+    }
93 93
 }
Please login to merge, or discard this patch.
lib/private/OCS/Result.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -32,127 +32,127 @@
 block discarded – undo
32 32
 
33 33
 class Result {
34 34
 
35
-	/** @var array  */
36
-	protected $data;
37
-
38
-	/** @var null|string */
39
-	protected $message;
40
-
41
-	/** @var int */
42
-	protected $statusCode;
43
-
44
-	/** @var integer */
45
-	protected $items;
46
-
47
-	/** @var integer */
48
-	protected $perPage;
49
-
50
-	/** @var array */
51
-	private $headers = [];
52
-
53
-	/**
54
-	 * create the OCS_Result object
55
-	 * @param mixed $data the data to return
56
-	 * @param int $code
57
-	 * @param null|string $message
58
-	 * @param array $headers
59
-	 */
60
-	public function __construct($data = null, $code = 100, $message = null, $headers = []) {
61
-		if ($data === null) {
62
-			$this->data = [];
63
-		} elseif (!is_array($data)) {
64
-			$this->data = [$this->data];
65
-		} else {
66
-			$this->data = $data;
67
-		}
68
-		$this->statusCode = $code;
69
-		$this->message = $message;
70
-		$this->headers = $headers;
71
-	}
72
-
73
-	/**
74
-	 * optionally set the total number of items available
75
-	 * @param int $items
76
-	 */
77
-	public function setTotalItems($items) {
78
-		$this->items = $items;
79
-	}
80
-
81
-	/**
82
-	 * optionally set the the number of items per page
83
-	 * @param int $items
84
-	 */
85
-	public function setItemsPerPage($items) {
86
-		$this->perPage = $items;
87
-	}
88
-
89
-	/**
90
-	 * get the status code
91
-	 * @return int
92
-	 */
93
-	public function getStatusCode() {
94
-		return $this->statusCode;
95
-	}
96
-
97
-	/**
98
-	 * get the meta data for the result
99
-	 * @return array
100
-	 */
101
-	public function getMeta() {
102
-		$meta = [];
103
-		$meta['status'] = $this->succeeded() ? 'ok' : 'failure';
104
-		$meta['statuscode'] = $this->statusCode;
105
-		$meta['message'] = $this->message;
106
-		if (isset($this->items)) {
107
-			$meta['totalitems'] = $this->items;
108
-		}
109
-		if (isset($this->perPage)) {
110
-			$meta['itemsperpage'] = $this->perPage;
111
-		}
112
-		return $meta;
113
-	}
114
-
115
-	/**
116
-	 * get the result data
117
-	 * @return array
118
-	 */
119
-	public function getData() {
120
-		return $this->data;
121
-	}
122
-
123
-	/**
124
-	 * return bool Whether the method succeeded
125
-	 * @return bool
126
-	 */
127
-	public function succeeded() {
128
-		return ($this->statusCode == 100);
129
-	}
130
-
131
-	/**
132
-	 * Adds a new header to the response
133
-	 * @param string $name The name of the HTTP header
134
-	 * @param string $value The value, null will delete it
135
-	 * @return $this
136
-	 */
137
-	public function addHeader($name, $value) {
138
-		$name = trim($name);  // always remove leading and trailing whitespace
139
-		// to be able to reliably check for security
140
-		// headers
141
-
142
-		if (is_null($value)) {
143
-			unset($this->headers[$name]);
144
-		} else {
145
-			$this->headers[$name] = $value;
146
-		}
147
-
148
-		return $this;
149
-	}
150
-
151
-	/**
152
-	 * Returns the set headers
153
-	 * @return array the headers
154
-	 */
155
-	public function getHeaders() {
156
-		return $this->headers;
157
-	}
35
+    /** @var array  */
36
+    protected $data;
37
+
38
+    /** @var null|string */
39
+    protected $message;
40
+
41
+    /** @var int */
42
+    protected $statusCode;
43
+
44
+    /** @var integer */
45
+    protected $items;
46
+
47
+    /** @var integer */
48
+    protected $perPage;
49
+
50
+    /** @var array */
51
+    private $headers = [];
52
+
53
+    /**
54
+     * create the OCS_Result object
55
+     * @param mixed $data the data to return
56
+     * @param int $code
57
+     * @param null|string $message
58
+     * @param array $headers
59
+     */
60
+    public function __construct($data = null, $code = 100, $message = null, $headers = []) {
61
+        if ($data === null) {
62
+            $this->data = [];
63
+        } elseif (!is_array($data)) {
64
+            $this->data = [$this->data];
65
+        } else {
66
+            $this->data = $data;
67
+        }
68
+        $this->statusCode = $code;
69
+        $this->message = $message;
70
+        $this->headers = $headers;
71
+    }
72
+
73
+    /**
74
+     * optionally set the total number of items available
75
+     * @param int $items
76
+     */
77
+    public function setTotalItems($items) {
78
+        $this->items = $items;
79
+    }
80
+
81
+    /**
82
+     * optionally set the the number of items per page
83
+     * @param int $items
84
+     */
85
+    public function setItemsPerPage($items) {
86
+        $this->perPage = $items;
87
+    }
88
+
89
+    /**
90
+     * get the status code
91
+     * @return int
92
+     */
93
+    public function getStatusCode() {
94
+        return $this->statusCode;
95
+    }
96
+
97
+    /**
98
+     * get the meta data for the result
99
+     * @return array
100
+     */
101
+    public function getMeta() {
102
+        $meta = [];
103
+        $meta['status'] = $this->succeeded() ? 'ok' : 'failure';
104
+        $meta['statuscode'] = $this->statusCode;
105
+        $meta['message'] = $this->message;
106
+        if (isset($this->items)) {
107
+            $meta['totalitems'] = $this->items;
108
+        }
109
+        if (isset($this->perPage)) {
110
+            $meta['itemsperpage'] = $this->perPage;
111
+        }
112
+        return $meta;
113
+    }
114
+
115
+    /**
116
+     * get the result data
117
+     * @return array
118
+     */
119
+    public function getData() {
120
+        return $this->data;
121
+    }
122
+
123
+    /**
124
+     * return bool Whether the method succeeded
125
+     * @return bool
126
+     */
127
+    public function succeeded() {
128
+        return ($this->statusCode == 100);
129
+    }
130
+
131
+    /**
132
+     * Adds a new header to the response
133
+     * @param string $name The name of the HTTP header
134
+     * @param string $value The value, null will delete it
135
+     * @return $this
136
+     */
137
+    public function addHeader($name, $value) {
138
+        $name = trim($name);  // always remove leading and trailing whitespace
139
+        // to be able to reliably check for security
140
+        // headers
141
+
142
+        if (is_null($value)) {
143
+            unset($this->headers[$name]);
144
+        } else {
145
+            $this->headers[$name] = $value;
146
+        }
147
+
148
+        return $this;
149
+    }
150
+
151
+    /**
152
+     * Returns the set headers
153
+     * @return array the headers
154
+     */
155
+    public function getHeaders() {
156
+        return $this->headers;
157
+    }
158 158
 }
Please login to merge, or discard this patch.
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.
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.
lib/private/Files/Storage/Home.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	public function __construct($arguments) {
51 51
 		$this->user = $arguments['user'];
52 52
 		$datadir = $this->user->getHome();
53
-		$this->id = 'home::' . $this->user->getUID();
53
+		$this->id = 'home::'.$this->user->getUID();
54 54
 
55 55
 		parent::__construct(['datadir' => $datadir]);
56 56
 	}
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -33,80 +33,80 @@
 block discarded – undo
33 33
  * Specialized version of Local storage for home directory usage
34 34
  */
35 35
 class Home extends Local implements \OCP\Files\IHomeStorage {
36
-	/**
37
-	 * @var string
38
-	 */
39
-	protected $id;
36
+    /**
37
+     * @var string
38
+     */
39
+    protected $id;
40 40
 
41
-	/**
42
-	 * @var \OC\User\User $user
43
-	 */
44
-	protected $user;
41
+    /**
42
+     * @var \OC\User\User $user
43
+     */
44
+    protected $user;
45 45
 
46
-	/**
47
-	 * Construct a Home storage instance
48
-	 *
49
-	 * @param array $arguments array with "user" containing the
50
-	 * storage owner
51
-	 */
52
-	public function __construct($arguments) {
53
-		$this->user = $arguments['user'];
54
-		$datadir = $this->user->getHome();
55
-		$this->id = 'home::' . $this->user->getUID();
46
+    /**
47
+     * Construct a Home storage instance
48
+     *
49
+     * @param array $arguments array with "user" containing the
50
+     * storage owner
51
+     */
52
+    public function __construct($arguments) {
53
+        $this->user = $arguments['user'];
54
+        $datadir = $this->user->getHome();
55
+        $this->id = 'home::' . $this->user->getUID();
56 56
 
57
-		parent::__construct(['datadir' => $datadir]);
58
-	}
57
+        parent::__construct(['datadir' => $datadir]);
58
+    }
59 59
 
60
-	public function getId() {
61
-		return $this->id;
62
-	}
60
+    public function getId() {
61
+        return $this->id;
62
+    }
63 63
 
64
-	/**
65
-	 * @return \OC\Files\Cache\HomeCache
66
-	 */
67
-	public function getCache($path = '', $storage = null) {
68
-		if (!$storage) {
69
-			$storage = $this;
70
-		}
71
-		if (!isset($this->cache)) {
72
-			$this->cache = new \OC\Files\Cache\HomeCache($storage);
73
-		}
74
-		return $this->cache;
75
-	}
64
+    /**
65
+     * @return \OC\Files\Cache\HomeCache
66
+     */
67
+    public function getCache($path = '', $storage = null) {
68
+        if (!$storage) {
69
+            $storage = $this;
70
+        }
71
+        if (!isset($this->cache)) {
72
+            $this->cache = new \OC\Files\Cache\HomeCache($storage);
73
+        }
74
+        return $this->cache;
75
+    }
76 76
 
77
-	/**
78
-	 * get a propagator instance for the cache
79
-	 *
80
-	 * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
81
-	 * @return \OC\Files\Cache\Propagator
82
-	 */
83
-	public function getPropagator($storage = null) {
84
-		if (!$storage) {
85
-			$storage = $this;
86
-		}
87
-		if (!isset($this->propagator)) {
88
-			$this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection());
89
-		}
90
-		return $this->propagator;
91
-	}
77
+    /**
78
+     * get a propagator instance for the cache
79
+     *
80
+     * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
81
+     * @return \OC\Files\Cache\Propagator
82
+     */
83
+    public function getPropagator($storage = null) {
84
+        if (!$storage) {
85
+            $storage = $this;
86
+        }
87
+        if (!isset($this->propagator)) {
88
+            $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection());
89
+        }
90
+        return $this->propagator;
91
+    }
92 92
 
93 93
 
94
-	/**
95
-	 * Returns the owner of this home storage
96
-	 *
97
-	 * @return \OC\User\User owner of this home storage
98
-	 */
99
-	public function getUser() {
100
-		return $this->user;
101
-	}
94
+    /**
95
+     * Returns the owner of this home storage
96
+     *
97
+     * @return \OC\User\User owner of this home storage
98
+     */
99
+    public function getUser() {
100
+        return $this->user;
101
+    }
102 102
 
103
-	/**
104
-	 * get the owner of a path
105
-	 *
106
-	 * @param string $path The path to get the owner
107
-	 * @return string uid or false
108
-	 */
109
-	public function getOwner($path) {
110
-		return $this->user->getUID();
111
-	}
103
+    /**
104
+     * get the owner of a path
105
+     *
106
+     * @param string $path The path to get the owner
107
+     * @return string uid or false
108
+     */
109
+    public function getOwner($path) {
110
+        return $this->user->getUID();
111
+    }
112 112
 }
Please login to merge, or discard this patch.
lib/private/Files/SimpleFS/SimpleFolder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 	public function getDirectoryListing() {
50 50
 		$listing = $this->folder->getDirectoryListing();
51 51
 
52
-		$fileListing = array_map(function (Node $file) {
52
+		$fileListing = array_map(function(Node $file) {
53 53
 			if ($file instanceof File) {
54 54
 				return new SimpleFile($file);
55 55
 			}
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -32,62 +32,62 @@
 block discarded – undo
32 32
 
33 33
 class SimpleFolder implements ISimpleFolder {
34 34
 
35
-	/** @var Folder */
36
-	private $folder;
37
-
38
-	/**
39
-	 * Folder constructor.
40
-	 *
41
-	 * @param Folder $folder
42
-	 */
43
-	public function __construct(Folder $folder) {
44
-		$this->folder = $folder;
45
-	}
46
-
47
-	public function getName() {
48
-		return $this->folder->getName();
49
-	}
50
-
51
-	public function getDirectoryListing() {
52
-		$listing = $this->folder->getDirectoryListing();
53
-
54
-		$fileListing = array_map(function (Node $file) {
55
-			if ($file instanceof File) {
56
-				return new SimpleFile($file);
57
-			}
58
-			return null;
59
-		}, $listing);
60
-
61
-		$fileListing = array_filter($fileListing);
62
-
63
-		return array_values($fileListing);
64
-	}
65
-
66
-	public function delete() {
67
-		$this->folder->delete();
68
-	}
69
-
70
-	public function fileExists($name) {
71
-		return $this->folder->nodeExists($name);
72
-	}
73
-
74
-	public function getFile($name) {
75
-		$file = $this->folder->get($name);
76
-
77
-		if (!($file instanceof File)) {
78
-			throw new NotFoundException();
79
-		}
80
-
81
-		return new SimpleFile($file);
82
-	}
83
-
84
-	public function newFile($name, $content = null) {
85
-		if ($content === null) {
86
-			// delay creating the file until it's written to
87
-			return new NewSimpleFile($this->folder, $name);
88
-		} else {
89
-			$file = $this->folder->newFile($name, $content);
90
-			return new SimpleFile($file);
91
-		}
92
-	}
35
+    /** @var Folder */
36
+    private $folder;
37
+
38
+    /**
39
+     * Folder constructor.
40
+     *
41
+     * @param Folder $folder
42
+     */
43
+    public function __construct(Folder $folder) {
44
+        $this->folder = $folder;
45
+    }
46
+
47
+    public function getName() {
48
+        return $this->folder->getName();
49
+    }
50
+
51
+    public function getDirectoryListing() {
52
+        $listing = $this->folder->getDirectoryListing();
53
+
54
+        $fileListing = array_map(function (Node $file) {
55
+            if ($file instanceof File) {
56
+                return new SimpleFile($file);
57
+            }
58
+            return null;
59
+        }, $listing);
60
+
61
+        $fileListing = array_filter($fileListing);
62
+
63
+        return array_values($fileListing);
64
+    }
65
+
66
+    public function delete() {
67
+        $this->folder->delete();
68
+    }
69
+
70
+    public function fileExists($name) {
71
+        return $this->folder->nodeExists($name);
72
+    }
73
+
74
+    public function getFile($name) {
75
+        $file = $this->folder->get($name);
76
+
77
+        if (!($file instanceof File)) {
78
+            throw new NotFoundException();
79
+        }
80
+
81
+        return new SimpleFile($file);
82
+    }
83
+
84
+    public function newFile($name, $content = null) {
85
+        if ($content === null) {
86
+            // delay creating the file until it's written to
87
+            return new NewSimpleFile($this->folder, $name);
88
+        } else {
89
+            $file = $this->folder->newFile($name, $content);
90
+            return new SimpleFile($file);
91
+        }
92
+    }
93 93
 }
Please login to merge, or discard this patch.
lib/private/Files/Stream/Quota.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -33,70 +33,70 @@
 block discarded – undo
33 33
  * usage: resource \OC\Files\Stream\Quota::wrap($stream, $limit)
34 34
  */
35 35
 class Quota extends Wrapper {
36
-	/**
37
-	 * @var int $limit
38
-	 */
39
-	private $limit;
36
+    /**
37
+     * @var int $limit
38
+     */
39
+    private $limit;
40 40
 
41
-	/**
42
-	 * @param resource $stream
43
-	 * @param int $limit
44
-	 * @return resource
45
-	 */
46
-	public static function wrap($stream, $limit) {
47
-		$context = stream_context_create([
48
-			'quota' => [
49
-				'source' => $stream,
50
-				'limit' => $limit
51
-			]
52
-		]);
53
-		return Wrapper::wrapSource($stream, $context, 'quota', self::class);
54
-	}
41
+    /**
42
+     * @param resource $stream
43
+     * @param int $limit
44
+     * @return resource
45
+     */
46
+    public static function wrap($stream, $limit) {
47
+        $context = stream_context_create([
48
+            'quota' => [
49
+                'source' => $stream,
50
+                'limit' => $limit
51
+            ]
52
+        ]);
53
+        return Wrapper::wrapSource($stream, $context, 'quota', self::class);
54
+    }
55 55
 
56
-	public function stream_open($path, $mode, $options, &$opened_path) {
57
-		$context = $this->loadContext('quota');
58
-		$this->source = $context['source'];
59
-		$this->limit = $context['limit'];
56
+    public function stream_open($path, $mode, $options, &$opened_path) {
57
+        $context = $this->loadContext('quota');
58
+        $this->source = $context['source'];
59
+        $this->limit = $context['limit'];
60 60
 
61
-		return true;
62
-	}
61
+        return true;
62
+    }
63 63
 
64
-	public function dir_opendir($path, $options) {
65
-		return false;
66
-	}
64
+    public function dir_opendir($path, $options) {
65
+        return false;
66
+    }
67 67
 
68
-	public function stream_seek($offset, $whence = SEEK_SET) {
69
-		if ($whence === SEEK_END) {
70
-			// go to the end to find out last position's offset
71
-			$oldOffset = $this->stream_tell();
72
-			if (fseek($this->source, 0, $whence) !== 0) {
73
-				return false;
74
-			}
75
-			$whence = SEEK_SET;
76
-			$offset = $this->stream_tell() + $offset;
77
-			$this->limit += $oldOffset - $offset;
78
-		} elseif ($whence === SEEK_SET) {
79
-			$this->limit += $this->stream_tell() - $offset;
80
-		} else {
81
-			$this->limit -= $offset;
82
-		}
83
-		// this wrapper needs to return "true" for success.
84
-		// the fseek call itself returns 0 on succeess
85
-		return fseek($this->source, $offset, $whence) === 0;
86
-	}
68
+    public function stream_seek($offset, $whence = SEEK_SET) {
69
+        if ($whence === SEEK_END) {
70
+            // go to the end to find out last position's offset
71
+            $oldOffset = $this->stream_tell();
72
+            if (fseek($this->source, 0, $whence) !== 0) {
73
+                return false;
74
+            }
75
+            $whence = SEEK_SET;
76
+            $offset = $this->stream_tell() + $offset;
77
+            $this->limit += $oldOffset - $offset;
78
+        } elseif ($whence === SEEK_SET) {
79
+            $this->limit += $this->stream_tell() - $offset;
80
+        } else {
81
+            $this->limit -= $offset;
82
+        }
83
+        // this wrapper needs to return "true" for success.
84
+        // the fseek call itself returns 0 on succeess
85
+        return fseek($this->source, $offset, $whence) === 0;
86
+    }
87 87
 
88
-	public function stream_read($count) {
89
-		$this->limit -= $count;
90
-		return fread($this->source, $count);
91
-	}
88
+    public function stream_read($count) {
89
+        $this->limit -= $count;
90
+        return fread($this->source, $count);
91
+    }
92 92
 
93
-	public function stream_write($data) {
94
-		$size = strlen($data);
95
-		if ($size > $this->limit) {
96
-			$data = substr($data, 0, $this->limit);
97
-			$size = $this->limit;
98
-		}
99
-		$this->limit -= $size;
100
-		return fwrite($this->source, $data);
101
-	}
93
+    public function stream_write($data) {
94
+        $size = strlen($data);
95
+        if ($size > $this->limit) {
96
+            $data = substr($data, 0, $this->limit);
97
+            $size = $this->limit;
98
+        }
99
+        $this->limit -= $size;
100
+        return fwrite($this->source, $data);
101
+    }
102 102
 }
Please login to merge, or discard this patch.