Completed
Push — master ( c04a49...30ca3b )
by Morris
33:00 queued 17:46
created

InvalidBackend::manipulateStorageConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * @author Vincent Petry <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2016, ownCloud GmbH.
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace OCA\Files_External\Lib\Backend;
23
24
use OCA\Files_External\Lib\Storage\InvalidStorage;
25
use OCA\Files_External\Lib\StorageConfig;
26
use OCP\Files\StorageNotAvailableException;
27
use OCP\IUser;
28
29
/**
30
 * Invalid storage backend representing a backend
31
 * that could not be resolved
32
 */
33
class InvalidBackend extends Backend {
34
35
	/** @var string Invalid backend id */
36
	private $invalidId;
37
38
	/**
39
	 * Constructs a new InvalidBackend with the id of the invalid backend
40
	 * for display purposes
41
	 *
42
	 * @param string $invalidId id of the backend that did not exist
43
	 */
44
	function __construct($invalidId) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
45
		$this->invalidId = $invalidId;
46
		$this
47
			->setIdentifier($invalidId)
48
			->setStorageClass('\OC\Files\Storage\FailedStorage')
49
			->setText('Unknown storage backend ' . $invalidId);
50
	}
51
52
	/**
53
	 * Returns the invalid backend id
54
	 *
55
	 * @return string invalid backend id
56
	 */
57
	public function getInvalidId() {
58
		return $this->invalidId;
59
	}
60
61
	public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
62
		$storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR));
63
	}
64
}
65
66