BuilderAbstract::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 4
b 0
f 0
nc 3
nop 1
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 3
rs 9.4285
1
<?php
2
3
namespace BryanCrowe\Growl\Builder;
4
5
use InvalidArgumentException;
6
7
/**
8
 * Abstract Builder class
9
 */
10
abstract class BuilderAbstract implements BuilderInterface
11
{
12
    /**
13
     * The notifier's path.
14
     *
15
     * @var string
16
     */
17
    protected $path;
18
19
    /**
20
     * Constructor. Offers an opportunity to set a notifier's alias/path.
21
     *
22
     * @param string|null $path The path to the notifier's CLI.
23
     * @throws \InvalidArgumentException If the argument isn't a string.
24
     */
25 42
    public function __construct($path = null)
26
    {
27 42
        if ($path === null) {
28 42
            return;
29
        }
30 9
        if (is_string($path)) {
31 9
            $this->path = $path;
32 9
            return;
33
        }
34
35 3
        throw new InvalidArgumentException(
36
            'This constructor expects a string argument.'
37 3
        );
38
    }
39
40
    /**
41
     * Build the command string to be executed.
42
     *
43
     * @param array $options An array of options to use for building the
44
     * command.
45
     * @return string
46
     */
47
    abstract public function build($options);
48
}
49