MemcachedFactory::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
/**
3
 * MemcachedFactory.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     Cache
10
 * @since          1.0.0
11
 *
12
 * @date           26.04.16
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\Flysystem\Factories\Cache;
18
19
use Nette\DI;
20
use Nette\Utils;
21
22
use League\Flysystem\Cached;
23
24
/**
25
 * Memcached cache
26
 *
27
 * @package        iPublikuj:Flysystem!
28
 * @subpackage     Cache
29
 *
30
 * @author         Adam Kadlec <[email protected]>
31
 */
32 View Code Duplication
class MemcachedFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
{
34
	/**
35
	 * @param Utils\ArrayHash $parameters
36
	 * @param DI\Container $container
37
	 *
38
	 * @return Cached\Storage\Memcached
39
	 */
40
	public static function create(Utils\ArrayHash $parameters, DI\Container $container) : Cached\Storage\Memcached
41
	{
42
		/** @var \Memcached $client */
43
		$client = $parameters->client ? $container->getService($parameters->client) : NULL;
44
45
		return new Cached\Storage\Memcached($client, $parameters->key, $parameters->expires);
46
	}
47
}
48