Passed
Push — master ( 894e98...cda682 )
by Aimeos
18:42 queued 10:10
created

FlyDropbox::getProvider()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 10
nc 5
nop 0
dl 0
loc 21
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2022
6
 * @package Base
7
 * @subpackage Filesystem
8
 */
9
10
11
namespace Aimeos\Base\Filesystem;
12
13
use Dropbox\Client;
0 ignored issues
show
Bug introduced by
The type Dropbox\Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use League\Flysystem\Filesystem;
15
use League\Flysystem\Dropbox\DropboxAdapter;
0 ignored issues
show
Bug introduced by
The type League\Flysystem\Dropbox\DropboxAdapter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
18
/**
19
 * Implementation of Flysystem Dropbox file system adapter
20
 *
21
 * @package Base
22
 * @subpackage Filesystem
23
 */
24
class FlyDropbox extends FlyBase implements Iface, DirIface, MetaIface
25
{
26
	private $fs;
27
28
29
	/**
30
	 * Returns the file system provider
31
	 *
32
	 * @return \League\Flysystem\FilesystemInterface File system provider
33
	 */
34
	protected function getProvider()
35
	{
36
		if( !isset( $this->fs ) )
37
		{
38
			$config = $this->getConfig();
39
40
			if( !isset( $config['accesstoken'] ) ) {
41
				throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'accesstoken' ) );
42
			}
43
44
			if( !isset( $config['appsecret'] ) ) {
45
				throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'appsecret' ) );
46
			}
47
48
			$prefix = ( isset( $config['prefix'] ) ? $config['prefix'] : null );
49
50
			$client = new Client( $config['accesstoken'], $config['appsecret'] );
51
			$this->fs = new Filesystem( new DropboxAdapter( $client, $prefix ) );
52
		}
53
54
		return $this->fs;
55
	}
56
}
57