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

FlyLocal::getProvider()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 0
dl 0
loc 15
rs 10
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\Adapter\Local;
15
16
17
/**
18
 * Implementation of Flysystem local file system adapter
19
 *
20
 * @package Base
21
 * @subpackage Filesystem
22
 */
23
class FlyLocal 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['basedir'] ) ) {
40
				throw new Exception( sprintf( 'Configuration option "%1$s" missing', 'basedir' ) );
41
			}
42
43
			$adapter = new Local( $config['basedir'], LOCK_EX, Local::SKIP_LINKS, $config );
44
			$this->fs = new Filesystem( $adapter );
45
		}
46
47
		return $this->fs;
48
	}
49
}
50