Total Complexity | 7 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 3 | ||
Bugs | 0 | Features | 3 |
1 | <?php |
||
12 | class Options |
||
13 | { |
||
14 | /** |
||
15 | * @var array protected to make use of it in OptionsMock for tests |
||
16 | */ |
||
17 | protected $definition; |
||
18 | |||
19 | /** |
||
20 | * @var Types used in the definition |
||
21 | */ |
||
22 | protected $types; |
||
23 | |||
24 | /** |
||
25 | * @return Options |
||
26 | */ |
||
27 | 4 | public static function create() |
|
28 | { |
||
29 | 4 | $definition = array( |
|
30 | 4 | 'docker.socket.path' => array('/var/run/docker.sock', null), |
|
31 | 'docker.client.path' => array('/usr/bin/docker', null), |
||
32 | 'script.exit-early' => array(false, null), |
||
33 | 4 | 'step.clone-path' => array('/app', Types::ABSPATH), |
|
34 | ); |
||
35 | |||
36 | 4 | return new self($definition, new Types()); |
|
37 | } |
||
38 | |||
39 | 4 | public function __construct(array $definition, Types $types = null) |
|
40 | { |
||
41 | 4 | $this->definition = $definition; |
|
42 | 4 | $this->types = $types; |
|
43 | 4 | } |
|
44 | |||
45 | /** |
||
46 | * @param string $name |
||
47 | * |
||
48 | * @return null|bool|string |
||
49 | */ |
||
50 | 2 | final public function get($name) |
|
51 | { |
||
52 | 2 | if (isset($this->definition[$name][0])) { |
|
53 | 2 | return $this->definition[$name][0]; |
|
54 | } |
||
55 | |||
56 | 2 | return null; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @param string $name |
||
61 | * @param string $value |
||
62 | * |
||
63 | * @return null|string |
||
64 | */ |
||
65 | 2 | final public function verify($name, $value) |
|
70 | } |
||
71 | } |
||
72 |