NotifySendBuilder::build()   B
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 8
Bugs 0 Features 2
Metric Value
cc 5
eloc 9
c 8
b 0
f 2
nc 8
nop 1
dl 0
loc 16
ccs 12
cts 12
cp 1
crap 5
rs 8.8571
1
<?php
2
3
namespace BryanCrowe\Growl\Builder;
4
5
/**
6
 * This class is a builder for notify-send commands.
7
 */
8
class NotifySendBuilder extends BuilderAbstract
9
{
10
    /**
11
     * The notifier's path.
12
     *
13
     * @var string
14
     */
15
    protected $path = 'notify-send';
16
17
    /**
18
     * Builds the notify-send 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 .= " {$options['title']}";
29 3
        }
30 3
        if (isset($options['message'])) {
31 3
            $command .= " {$options['message']}";
32 3
        }
33 3
        if (isset($options['sticky']) && $options['sticky'] === true) {
34 3
            $command .= ' -t 0';
35 3
        }
36
37 3
        return $command;
38
    }
39
}
40