TerminalNotifierBuilder::build()   C
last analyzed

Complexity

Conditions 7
Paths 64

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 7

Importance

Changes 10
Bugs 0 Features 2
Metric Value
cc 7
eloc 15
c 10
b 0
f 2
nc 64
nop 1
dl 0
loc 25
ccs 21
cts 21
cp 1
crap 7
rs 6.7272
1
<?php
2
3
namespace BryanCrowe\Growl\Builder;
4
5
/**
6
 * This class is a builder for terminal-notifier commands.
7
 */
8
class TerminalNotifierBuilder extends BuilderAbstract
9
{
10
    /**
11
     * The notifier's path.
12
     *
13
     * @var string
14
     */
15
    protected $path = 'terminal-notifier';
16
17
    /**
18
     * Builds the terminal-notifier command to be executed.
19
     *
20
     * @param array $options An array of options to use for building the command.
21
     * @return string The fully-built command to execute.
22
     */
23 3
    public function build($options)
24
    {
25 3
        $command = $this->path;
26
27 3
        if (isset($options['title'])) {
28 3
            $command .= " -title {$options['title']}";
29 3
        }
30 3
        if (isset($options['subtitle'])) {
31 3
            $command .= " -subtitle {$options['subtitle']}";
32 3
        }
33 3
        if (isset($options['message'])) {
34 3
            $command .= " -message {$options['message']}";
35 3
        }
36 3
        if (isset($options['image'])) {
37 3
            $command .= " -appIcon {$options['image']}";
38 3
        }
39 3
        if (isset($options['contentImage'])) {
40 3
            $command .= " -contentImage {$options['contentImage']}";
41 3
        }
42 3
        if (isset($options['url'])) {
43 3
            $command .= " -open {$options['url']}";
44 3
        }
45
46 3
        return $command;
47
    }
48
}
49