Passed
Push — master ( ff8f2e...aaaf39 )
by Aimeos
02:27
created

FlyGoogleCloud   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getProvider() 0 17 3
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 League\Flysystem\Filesystem;
14
use League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter;
0 ignored issues
show
Bug introduced by
The type League\Flysystem\GoogleC...ogleCloudStorageAdapter 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...
15
use Google\Cloud\Storage\StorageClient;
0 ignored issues
show
Bug introduced by
The type Google\Cloud\Storage\StorageClient 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 AWS file system adapter
20
 *
21
 * @package Base
22
 * @subpackage Filesystem
23
 */
24
class FlyGoogleCloud 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
0 ignored issues
show
Bug introduced by
The type League\Flysystem\FilesystemInterface 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...
33
	 */
34
	protected function getProvider()
35
	{
36
		if( !isset( $this->fs ) )
37
		{
38
			$config = $this->getConfig();
39
40
			if( !isset( $config['bucket'] ) ) {
41
				throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'bucket' ) );
42
			}
43
44
			$client = new StorageClient( $config );
0 ignored issues
show
Unused Code introduced by
The assignment to $client is dead and can be removed.
Loading history...
45
			$bucket = $storageClient->bucket( $config['bucket'] );
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $storageClient seems to be never defined.
Loading history...
46
			$adapter = new GoogleCloudStorageAdapter( $bucket, $config['prefix'] ?? '' );
47
			$this->fs = new Filesystem( $adapter );
48
		}
49
50
		return $this->fs;
51
	}
52
}
53