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

FlyReplicate::getProvider()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 0
dl 0
loc 20
rs 9.9332
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 League\Flysystem\Filesystem;
14
use League\Flysystem\Replicate\ReplicateAdapter;
0 ignored issues
show
Bug introduced by
The type League\Flysystem\Replicate\ReplicateAdapter 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
16
17
/**
18
 * Implementation of Flysystem Replicate file system adapter
19
 *
20
 * @package Base
21
 * @subpackage Filesystem
22
 */
23
class FlyReplicate extends FlyBase implements Iface, DirIface, MetaIface
24
{
25
	private $fs;
26
27
28
	/**
29
	 * Returns the file system provider
30
	 *
31
	 * @return \League\Flysystem\FilesystemInterface File system provider
32
	 */
33
	protected function getProvider()
34
	{
35
		if( !isset( $this->fs ) )
36
		{
37
			$config = $this->getConfig();
38
39
			if( !isset( $config['source'] ) ) {
40
				throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'source' ) );
41
			}
42
43
			if( !isset( $config['replica'] ) ) {
44
				throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'replica' ) );
45
			}
46
47
			$source = Factory::create( (array) $config['source'] )->getAdapter();
0 ignored issues
show
Bug introduced by
The method getAdapter() does not exist on Aimeos\Base\Filesystem\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\Base\Filesystem\Standard. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
			$source = Factory::create( (array) $config['source'] )->/** @scrutinizer ignore-call */ getAdapter();
Loading history...
48
			$replica = Factory::create( (array) $config['replica'] )->getAdapter();
49
			$this->fs = new Filesystem( new ReplicateAdapter( $source, $replica ) );
50
		}
51
52
		return $this->fs;
53
	}
54
}
55