Passed
Push — master ( 26e86a...9b47e1 )
by Tom
03:10
created

Options   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 39
ccs 9
cts 9
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getDocker() 0 3 1
A parseOptions() 0 7 2
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\File;
6
7
use Ktomk\Pipelines\Lib;
8
9
/**
10
 * Definitions node in pipelines file
11
 *
12
 * @package Ktomk\Pipelines\File
13
 */
14
class Options
15
{
16
    /**
17
     * @var array
18
     */
19
    private $array;
20
21
    /**
22
     * Definitions constructor.
23
     *
24
     * @param array $array
25
     */
26 3
    public function __construct(array $array)
27
    {
28 3
        Lib::v($array['docker'], false);
29
30 3
        $this->array = $this->parseOptions($array);
31
    }
32
33
    /**
34
     * @return bool
35
     */
36 1
    public function getDocker()
37
    {
38 1
        return (bool)$this->array['docker'];
39
    }
40
41
    /**
42
     * @param array $array
43
     *
44
     * @return array
45
     */
46 3
    private function parseOptions(array $array)
47
    {
48 3
        if (!is_bool($array['docker'])) {
49 1
            throw new ParseException(sprintf("global option 'docker' should be a boolean, it is currently defined %s", gettype($array['docker'])));
50
        }
51
52 2
        return $array;
53
    }
54
}
55