RedisFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Mutex Library.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace AMF\Mutex\Storage\Redis;
11
12
use AMF\Mutex\Storage\StorageFactoryInterface;
13
use Predis\Client;
14
15
/**
16
 * Factory for creating a redis instance.
17
 *
18
 * @author Amine Fattouch <[email protected]>
19
 */
20
class RedisFactory implements StorageFactoryInterface
21
{
22
    /**
23
     * @var array
24
     */
25
    private $parameters = [
26
        'host'   => ['localhost'],
27
        'port'   => 6379,
28
        'scheme' => 'tcp',
29
    ];
30
31
    /**
32
     * Constructor class.
33
     *
34
     * @param array $parameters
35
     */
36
    public function __construct(array $parameters = [])
37
    {
38
        $this->parameters = array_merge($this->parameters, $parameters);
39
    }
40
41
    /**
42
     * Creates an instance of redis.
43
     *
44
     * @return Client
45
     */
46
    public function create()
47
    {
48
        return new Client($this->parameters);
49
    }
50
}
51