Passed
Push — test ( b9bc22...335b2e )
by Tom
02:36
created

RunOpts   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 94
ccs 21
cts 21
cp 1
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setPrefix() 0 3 1
A getOption() 0 7 2
A create() 0 3 1
A setBinaryPackage() 0 3 1
A getPrefix() 0 3 1
A getBinaryPackage() 0 3 1
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Runner;
6
7
use Ktomk\Pipelines\Utility\Options;
8
9
/**
10
 * Runner options parameter object
11
 */
12
class RunOpts
13
{
14
    /**
15
     * @var string
16
     */
17
    private $prefix;
18
19
    /**
20
     * @var Options
21
     */
22
    private $options;
23
24
    /**
25
     * @var string
26
     */
27
    private $binaryPackage;
28
29
    /**
30
     * Static factory method
31
     *
32
     * @param string $prefix [optional]
33
     * @param string $binaryPackage package name or path to binary (string)
34
     *
35
     * @return RunOpts
36
     */
37 1
    public static function create($prefix = null, $binaryPackage = null)
38
    {
39 1
        return new self($prefix, Options::create(), $binaryPackage);
40
    }
41
42
    /**
43
     * RunOpts constructor.
44
     *
45
     * NOTE: All run options are optional by design (pass NULL).
46
     *
47
     * @param string $prefix
48
     * @param null|Options $options
49
     * @param string $binaryPackage package name or path to binary (string)
50
     */
51 2
    public function __construct($prefix = null, Options $options = null, $binaryPackage = null)
52
    {
53 2
        $this->prefix = $prefix;
54 2
        $this->options = $options;
55 2
        $this->binaryPackage = $binaryPackage;
56 2
    }
57
58
    /**
59
     * @param string $prefix
60
     */
61 1
    public function setPrefix($prefix)
62
    {
63 1
        $this->prefix = $prefix;
64 1
    }
65
66
    /**
67
     * The prefix is used when creating containers for the container name.
68
     *
69
     * See --prefix option.
70
     *
71
     * @return string
72
     */
73 1
    public function getPrefix()
74
    {
75 1
        return $this->prefix;
76
    }
77
78
    /**
79
     * @param string $name
80
     *
81
     * @return null|string
82
     */
83 2
    public function getOption($name)
84
    {
85 2
        if (!isset($this->options)) {
86 1
            return null;
87
        }
88
89 1
        return $this->options->get($name);
90
    }
91
92
    /**
93
     * @param string $binaryPackage
94
     */
95 1
    public function setBinaryPackage($binaryPackage)
96
    {
97 1
        $this->binaryPackage = $binaryPackage;
98 1
    }
99
100
    /**
101
     * @return string
102
     */
103 1
    public function getBinaryPackage()
104
    {
105 1
        return $this->binaryPackage;
106
    }
107
}
108