Passed
Push — test ( 8d4b30...f689e2 )
by Tom
02:36
created

Options::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Utility;
6
7
/**
8
 * application options store
9
 */
10
class Options
11
{
12
    /**
13
     * @var array protected to make use of it in OptionsMock for tests
14
     */
15
    protected $definition;
16
17
    /**
18
     * @return Options
19
     */
20 2
    public static function create()
21
    {
22
        $definition = array(
23 2
            'docker.socket.path' => array('/var/run/docker.sock'),
24
        );
25
26 2
        return new self($definition);
27
    }
28
29 2
    public function __construct(array $definition)
30
    {
31 2
        $this->definition = $definition;
32 2
    }
33
34
    /**
35
     * @param string $name
36
     *
37
     * @return null|string
38
     */
39 2
    final public function get($name)
40
    {
41 2
        if (isset($this->definition[$name][0])) {
42 2
            return $this->definition[$name][0];
43
        }
44
45 2
        return null;
46
    }
47
}
48