Completed
Push — master ( 0cff70...dba08f )
by Morris
09:32
created

SMB   D

Complexity

Total Complexity 86

Size/Duplication

Total Lines 352
Duplicated Lines 16.19 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 86
lcom 1
cbo 6
dl 57
loc 352
rs 4.8717
c 1
b 1
f 0

20 Methods

Rating   Name   Duplication   Size   Complexity  
C __construct() 3 21 10
A getId() 0 6 1
A buildPath() 0 3 1
A getFileInfo() 0 11 3
A getFolderContents() 0 12 3
A formatInfo() 0 6 1
A stat() 0 3 1
B unlink() 0 18 5
A hasUpdated() 0 10 3
F fopen() 11 60 23
B rmdir() 0 21 6
A touch() 12 12 3
A opendir() 0 14 3
A filetype() 0 9 4
A mkdir() 11 11 3
A file_exists() 0 12 4
A isReadable() 10 10 3
A isUpdatable() 10 10 4
A checkDependencies() 0 6 3
A test() 0 7 2

How to fix   Duplicated Code    Complexity   

Duplicated Code

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:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like SMB often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use SMB, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * @author Arthur Schiwon <[email protected]>
4
 * @author Jesús Macias <[email protected]>
5
 * @author Jörn Friedrich Dreyer <[email protected]>
6
 * @author Michael Gapczynski <[email protected]>
7
 * @author Morris Jobke <[email protected]>
8
 * @author Philipp Kapfer <[email protected]>
9
 * @author Robin Appelman <[email protected]>
10
 * @author Robin McCorkell <[email protected]>
11
 * @author Thomas Müller <[email protected]>
12
 * @author Vincent Petry <[email protected]>
13
 *
14
 * @copyright Copyright (c) 2016, ownCloud, Inc.
15
 * @license AGPL-3.0
16
 *
17
 * This code is free software: you can redistribute it and/or modify
18
 * it under the terms of the GNU Affero General Public License, version 3,
19
 * as published by the Free Software Foundation.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License, version 3,
27
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
28
 *
29
 */
30
31
namespace OCA\Files_External\Lib\Storage;
32
33
use Icewind\SMB\Exception\ConnectException;
34
use Icewind\SMB\Exception\Exception;
35
use Icewind\SMB\Exception\ForbiddenException;
36
use Icewind\SMB\Exception\NotFoundException;
37
use Icewind\SMB\NativeServer;
38
use Icewind\SMB\Server;
39
use Icewind\Streams\CallbackWrapper;
40
use Icewind\Streams\IteratorDirectory;
41
use OC\Cache\CappedMemoryCache;
42
use OC\Files\Filesystem;
43
use OCP\Files\StorageNotAvailableException;
44
45
class SMB extends \OC\Files\Storage\Common {
46
	/**
47
	 * @var \Icewind\SMB\Server
48
	 */
49
	protected $server;
50
51
	/**
52
	 * @var \Icewind\SMB\Share
53
	 */
54
	protected $share;
55
56
	/**
57
	 * @var string
58
	 */
59
	protected $root;
60
61
	/**
62
	 * @var \Icewind\SMB\FileInfo[]
63
	 */
64
	protected $statCache;
65
66
	public function __construct($params) {
67
		if (isset($params['host']) && isset($params['user']) && isset($params['password']) && isset($params['share'])) {
68
			if (Server::NativeAvailable()) {
69
				$this->server = new NativeServer($params['host'], $params['user'], $params['password']);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Icewind\SMB\NativeS...], $params['password']) of type object<Icewind\SMB\NativeServer> is incompatible with the declared type object<Icewind\SMB\Server> of property $server.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
70
			} else {
71
				$this->server = new Server($params['host'], $params['user'], $params['password']);
72
			}
73
			$this->share = $this->server->getShare(trim($params['share'], '/'));
74
75
			$this->root = isset($params['root']) ? $params['root'] : '/';
76 View Code Duplication
			if (!$this->root || $this->root[0] != '/') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
77
				$this->root = '/' . $this->root;
78
			}
79
			if (substr($this->root, -1, 1) != '/') {
80
				$this->root .= '/';
81
			}
82
		} else {
83
			throw new \Exception('Invalid configuration');
84
		}
85
		$this->statCache = new CappedMemoryCache();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \OC\Cache\CappedMemoryCache() of type object<OC\Cache\CappedMemoryCache> is incompatible with the declared type array<integer,object<Icewind\SMB\FileInfo>> of property $statCache.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
86
	}
87
88
	/**
89
	 * @return string
90
	 */
91
	public function getId() {
92
		// FIXME: double slash to keep compatible with the old storage ids,
93
		// failure to do so will lead to creation of a new storage id and
94
		// loss of shares from the storage
95
		return 'smb::' . $this->server->getUser() . '@' . $this->server->getHost() . '//' . $this->share->getName() . '/' . $this->root;
96
	}
97
98
	/**
99
	 * @param string $path
100
	 * @return string
101
	 */
102
	protected function buildPath($path) {
103
		return Filesystem::normalizePath($this->root . '/' . $path);
104
	}
105
106
	/**
107
	 * @param string $path
108
	 * @return \Icewind\SMB\IFileInfo
109
	 * @throws StorageNotAvailableException
110
	 */
111
	protected function getFileInfo($path) {
112
		try {
113
			$path = $this->buildPath($path);
114
			if (!isset($this->statCache[$path])) {
115
				$this->statCache[$path] = $this->share->stat($path);
116
			}
117
			return $this->statCache[$path];
118
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
119
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
120
		}
121
	}
122
123
	/**
124
	 * @param string $path
125
	 * @return \Icewind\SMB\IFileInfo[]
126
	 * @throws StorageNotAvailableException
127
	 */
128
	protected function getFolderContents($path) {
129
		try {
130
			$path = $this->buildPath($path);
131
			$files = $this->share->dir($path);
132
			foreach ($files as $file) {
133
				$this->statCache[$path . '/' . $file->getName()] = $file;
134
			}
135
			return $files;
136
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
137
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
138
		}
139
	}
140
141
	/**
142
	 * @param \Icewind\SMB\IFileInfo $info
143
	 * @return array
144
	 */
145
	protected function formatInfo($info) {
146
		return array(
147
			'size' => $info->getSize(),
148
			'mtime' => $info->getMTime()
149
		);
150
	}
151
152
	/**
153
	 * @param string $path
154
	 * @return array
155
	 */
156
	public function stat($path) {
157
		return $this->formatInfo($this->getFileInfo($path));
158
	}
159
160
	/**
161
	 * @param string $path
162
	 * @return bool
163
	 */
164
	public function unlink($path) {
165
		try {
166
			if ($this->is_dir($path)) {
167
				return $this->rmdir($path);
168
			} else {
169
				$path = $this->buildPath($path);
170
				unset($this->statCache[$path]);
171
				$this->share->del($path);
172
				return true;
173
			}
174
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
175
			return false;
176
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
177
			return false;
178
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
179
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
180
		}
181
	}
182
183
	/**
184
	 * check if a file or folder has been updated since $time
185
	 *
186
	 * @param string $path
187
	 * @param int $time
188
	 * @return bool
189
	 */
190
	public function hasUpdated($path, $time) {
191
		if (!$path and $this->root == '/') {
192
			// mtime doesn't work for shares, but giving the nature of the backend,
193
			// doing a full update is still just fast enough
194
			return true;
195
		} else {
196
			$actualTime = $this->filemtime($path);
197
			return $actualTime > $time;
198
		}
199
	}
200
201
	/**
202
	 * @param string $path
203
	 * @param string $mode
204
	 * @return resource
205
	 */
206
	public function fopen($path, $mode) {
207
		$fullPath = $this->buildPath($path);
208
		try {
209
			switch ($mode) {
210
				case 'r':
211
				case 'rb':
212
					if (!$this->file_exists($path)) {
213
						return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by OCA\Files_External\Lib\Storage\SMB::fopen of type resource.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
214
					}
215
					return $this->share->read($fullPath);
216
				case 'w':
217
				case 'wb':
218
					$source = $this->share->write($fullPath);
219
					return CallBackWrapper::wrap($source, null, null, function () use ($fullPath) {
220
						unset($this->statCache[$fullPath]);
221
					});
222
				case 'a':
223
				case 'ab':
224
				case 'r+':
225
				case 'w+':
226
				case 'wb+':
227
				case 'a+':
228
				case 'x':
229
				case 'x+':
230
				case 'c':
231
				case 'c+':
232
					//emulate these
233
					if (strrpos($path, '.') !== false) {
234
						$ext = substr($path, strrpos($path, '.'));
235
					} else {
236
						$ext = '';
237
					}
238 View Code Duplication
					if ($this->file_exists($path)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
239
						if (!$this->isUpdatable($path)) {
240
							return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by OCA\Files_External\Lib\Storage\SMB::fopen of type resource.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
241
						}
242
						$tmpFile = $this->getCachedFile($path);
243
					} else {
244
						if (!$this->isCreatable(dirname($path))) {
245
							return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by OCA\Files_External\Lib\Storage\SMB::fopen of type resource.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
246
						}
247
						$tmpFile = \OCP\Files::tmpFile($ext);
248
					}
249
					$source = fopen($tmpFile, $mode);
250
					$share = $this->share;
251
					return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath, $share) {
252
						unset($this->statCache[$fullPath]);
253
						$share->put($tmpFile, $fullPath);
254
						unlink($tmpFile);
255
					});
256
			}
257
			return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by OCA\Files_External\Lib\Storage\SMB::fopen of type resource.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
258
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
259
			return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by OCA\Files_External\Lib\Storage\SMB::fopen of type resource.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
260
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
261
			return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by OCA\Files_External\Lib\Storage\SMB::fopen of type resource.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
262
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
263
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
264
		}
265
	}
266
267
	public function rmdir($path) {
268
		try {
269
			$this->statCache = array();
270
			$content = $this->share->dir($this->buildPath($path));
271
			foreach ($content as $file) {
272
				if ($file->isDirectory()) {
273
					$this->rmdir($path . '/' . $file->getName());
274
				} else {
275
					$this->share->del($file->getPath());
276
				}
277
			}
278
			$this->share->rmdir($this->buildPath($path));
279
			return true;
280
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
281
			return false;
282
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
283
			return false;
284
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
285
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
286
		}
287
	}
288
289 View Code Duplication
	public function touch($path, $time = null) {
290
		try {
291
			if (!$this->file_exists($path)) {
292
				$fh = $this->share->write($this->buildPath($path));
293
				fclose($fh);
294
				return true;
295
			}
296
			return false;
297
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
298
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
299
		}
300
	}
301
302
	public function opendir($path) {
303
		try {
304
			$files = $this->getFolderContents($path);
305
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
306
			return false;
307
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
308
			return false;
309
		}
310
		$names = array_map(function ($info) {
311
			/** @var \Icewind\SMB\IFileInfo $info */
312
			return $info->getName();
313
		}, $files);
314
		return IteratorDirectory::wrap($names);
315
	}
316
317
	public function filetype($path) {
318
		try {
319
			return $this->getFileInfo($path)->isDirectory() ? 'dir' : 'file';
320
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
321
			return false;
322
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
323
			return false;
324
		}
325
	}
326
327 View Code Duplication
	public function mkdir($path) {
328
		$path = $this->buildPath($path);
329
		try {
330
			$this->share->mkdir($path);
331
			return true;
332
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
333
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
334
		} catch (Exception $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
335
			return false;
336
		}
337
	}
338
339
	public function file_exists($path) {
340
		try {
341
			$this->getFileInfo($path);
342
			return true;
343
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
344
			return false;
345
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
346
			return false;
347
		} catch (ConnectException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ConnectException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
348
			throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
349
		}
350
	}
351
352 View Code Duplication
	public function isReadable($path) {
353
		try {
354
			$info = $this->getFileInfo($path);
355
			return !$info->isHidden();
356
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
357
			return false;
358
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
359
			return false;
360
		}
361
	}
362
363 View Code Duplication
	public function isUpdatable($path) {
364
		try {
365
			$info = $this->getFileInfo($path);
366
			return !$info->isHidden() && !$info->isReadOnly();
367
		} catch (NotFoundException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\NotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
368
			return false;
369
		} catch (ForbiddenException $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\ForbiddenException does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
370
			return false;
371
		}
372
	}
373
374
	/**
375
	 * check if smbclient is installed
376
	 */
377
	public static function checkDependencies() {
378
		return (
379
			(bool)\OC_Helper::findBinaryPath('smbclient')
380
			|| Server::NativeAvailable()
381
		) ? true : ['smbclient'];
382
	}
383
384
	/**
385
	 * Test a storage for availability
386
	 *
387
	 * @return bool
388
	 */
389
	public function test() {
390
		try {
391
			return parent::test();
392
		} catch (Exception $e) {
1 ignored issue
show
Bug introduced by
The class Icewind\SMB\Exception\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

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.

Loading history...
393
			return false;
394
		}
395
	}
396
}
397