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

Options::parseOptions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
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