Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
35 | class Storage extends DAV implements ISharedStorage { |
||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $remoteUser; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $remote; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $mountPoint; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | private $token; |
||
55 | |||
56 | /** |
||
57 | * @var \OCP\ICertificateManager |
||
58 | */ |
||
59 | private $certificateManager; |
||
60 | |||
61 | private $updateChecked = false; |
||
62 | |||
63 | /** |
||
64 | * @var \OCA\Files_Sharing\External\Manager |
||
65 | */ |
||
66 | private $manager; |
||
67 | |||
68 | 7 | public function __construct($options) { |
|
69 | 7 | $this->manager = $options['manager']; |
|
70 | 7 | $this->certificateManager = $options['certificateManager']; |
|
71 | 7 | $this->remote = $options['remote']; |
|
72 | 7 | $this->remoteUser = $options['owner']; |
|
73 | 7 | list($protocol, $remote) = explode('://', $this->remote); |
|
74 | 7 | if (strpos($remote, '/')) { |
|
75 | 6 | list($host, $root) = explode('/', $remote, 2); |
|
76 | 6 | } else { |
|
77 | 1 | $host = $remote; |
|
78 | 1 | $root = ''; |
|
79 | } |
||
80 | 7 | $secure = $protocol === 'https'; |
|
81 | 7 | $root = rtrim($root, '/') . '/public.php/webdav'; |
|
82 | 7 | $this->mountPoint = $options['mountpoint']; |
|
83 | 7 | $this->token = $options['token']; |
|
84 | 7 | parent::__construct(array( |
|
85 | 7 | 'secure' => $secure, |
|
86 | 7 | 'host' => $host, |
|
87 | 7 | 'root' => $root, |
|
88 | 7 | 'user' => $options['token'], |
|
89 | 7 | 'password' => (string)$options['password'] |
|
90 | 7 | )); |
|
91 | |||
92 | 7 | $this->getWatcher()->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); |
|
93 | 7 | } |
|
94 | |||
95 | public function getRemoteUser() { |
||
98 | |||
99 | public function getRemote() { |
||
102 | |||
103 | public function getMountPoint() { |
||
106 | |||
107 | public function getToken() { |
||
110 | |||
111 | public function getPassword() { |
||
114 | |||
115 | /** |
||
116 | * @brief get id of the mount point |
||
117 | * @return string |
||
118 | */ |
||
119 | 7 | public function getId() { |
|
122 | |||
123 | 7 | public function getCache($path = '', $storage = null) { |
|
124 | 7 | if (is_null($this->cache)) { |
|
125 | 7 | $this->cache = new Cache($this, $this->remote, $this->remoteUser); |
|
126 | 7 | } |
|
127 | 7 | return $this->cache; |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * @param string $path |
||
132 | * @param \OC\Files\Storage\Storage $storage |
||
133 | * @return \OCA\Files_Sharing\External\Scanner |
||
134 | */ |
||
135 | 7 | View Code Duplication | public function getScanner($path = '', $storage = null) { |
136 | 7 | if (!$storage) { |
|
137 | 7 | $storage = $this; |
|
138 | 7 | } |
|
139 | 7 | if (!isset($this->scanner)) { |
|
140 | 7 | $this->scanner = new Scanner($storage); |
|
141 | 7 | } |
|
142 | 7 | return $this->scanner; |
|
143 | } |
||
144 | |||
145 | /** |
||
146 | * check if a file or folder has been updated since $time |
||
147 | * |
||
148 | * @param string $path |
||
149 | * @param int $time |
||
150 | * @throws \OCP\Files\StorageNotAvailableException |
||
151 | * @throws \OCP\Files\StorageInvalidException |
||
152 | * @return bool |
||
153 | */ |
||
154 | public function hasUpdated($path, $time) { |
||
173 | |||
174 | /** |
||
175 | * Check whether this storage is permanently or temporarily |
||
176 | * unavailable |
||
177 | * |
||
178 | * @throws \OCP\Files\StorageNotAvailableException |
||
179 | * @throws \OCP\Files\StorageInvalidException |
||
180 | */ |
||
181 | public function checkStorageAvailability() { |
||
211 | |||
212 | public function file_exists($path) { |
||
219 | |||
220 | /** |
||
221 | * check if the configured remote is a valid ownCloud instance |
||
222 | * |
||
223 | * @return bool |
||
224 | */ |
||
225 | protected function testRemote() { |
||
234 | |||
235 | /** |
||
236 | * @return mixed |
||
237 | * @throws ForbiddenException |
||
238 | * @throws NotFoundException |
||
239 | * @throws \Exception |
||
240 | */ |
||
241 | public function getShareInfo() { |
||
266 | |||
267 | public function isSharable($path) { |
||
273 | } |
||
274 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.