Factory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 46.67%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 34
ccs 7
cts 15
cp 0.4667
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 23 6
1
<?php
2
3
namespace SyncFS\Client;
4
5
/**
6
 * Class Factory
7
 *
8
 * @package SyncFS\Client
9
 * @author  Matej Velikonja <[email protected]>
10
 */
11
class Factory
12
{
13
    /**
14
     * @param string $name
15
     * @param array  $options
16
     *
17
     * @throws \InvalidArgumentException
18
     *
19
     * @return ClientInterface
20
     */
21 2
    public function create($name, array $options = array())
22
    {
23 2
        $client = null;
24
25
        switch ($name) {
26 2
            case 'rsync':
27 2
                $client = new RsyncClient($options);
28 2
                break;
29
            case 'mock':
30
            case 'test':
31
                $client = new MockClient();
32
                break;
33
            case 'copy':
34
                $client = new CopyClient();
35
                break;
36
        }
37
38 2
        if (! $client) {
39
            throw new \InvalidArgumentException(sprintf('Client `%s` does not exists.', $name));
40
        }
41
42 2
        return $client;
43
    }
44
}
45