LocalFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 30
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A getLinks() 0 7 1
1
<?php
2
/**
3
 * LocalFactory.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
8
 * @package        iPublikuj:Flysystem!
9
 * @subpackage     Adapters
10
 * @since          1.0.0
11
 *
12
 * @date           12.04.16
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\Flysystem\Factories\Adapters;
18
19
use Nette\Utils;
20
21
use League\Flysystem\Adapter;
22
23
/**
24
 * Local adapter filesystem factory
25
 *
26
 * @package        iPublikuj:Flysystem!
27
 * @subpackage     Adapters
28
 *
29
 * @author         Adam Kadlec <[email protected]>
30
 */
31 1
class LocalFactory
32
{
33
	private const SKIP_LINKS = 'skipLinks';
34
	private const DISALLOW_LINKS = 'disallowLinks';
35
36
	/**
37
	 * @param Utils\ArrayHash $parameters
38
	 *
39
	 * @return Adapter\Local
40
	 */
41
	public static function create(Utils\ArrayHash $parameters) : Adapter\Local
42
	{
43 1
		return new Adapter\Local(
44 1
			$parameters->directory,
45 1
			$parameters->writeFlags,
46 1
			self::getLinks()[$parameters->linkHandling]
47
		);
48
	}
49
50
	/**
51
	 * @return array
52
	 */
53
	private static function getLinks() : array
54
	{
55
		return [
56 1
			self::SKIP_LINKS     => Adapter\Local::SKIP_LINKS,
57
			self::DISALLOW_LINKS => Adapter\Local::DISALLOW_LINKS,
58
		];
59
	}
60
}
61