FlyAwsS3   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getProvider() 0 18 4
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2018
6
 * @package MW
7
 * @subpackage Filesystem
8
 */
9
10
11
namespace Aimeos\MW\Filesystem;
12
13
use Aws\S3\S3Client;
0 ignored issues
show
Bug introduced by Aimeos
The type Aws\S3\S3Client 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\AwsS3v3\AwsS3Adapter;
0 ignored issues
show
Bug introduced by Aimeos
The type League\Flysystem\AwsS3v3\AwsS3Adapter 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 MW
22
 * @subpackage Filesystem
23
 */
24
class FlyAwsS3 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['bucket'] ) ) {
41
				throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'bucket' ) );
42
			}
43
44
			$prefix = ( isset( $config['prefix'] ) ? $config['prefix'] : null );
45
46
			$client = S3Client::factory( $config );
47
			$adapter = new AwsS3Adapter( $client, $config['bucket'], $prefix );
48
			$this->fs = new Filesystem( $adapter );
49
		}
50
51
		return $this->fs;
52
	}
53
}
54