GrowlNotifyBuilder   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 18
Bugs 0 Features 6
Metric Value
wmc 8
c 18
b 0
f 6
lcom 1
cbo 1
dl 0
loc 43
ccs 22
cts 22
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C build() 0 27 8
1
<?php
2
3
namespace BryanCrowe\Growl\Builder;
4
5
/**
6
 * This class is a builder for growlnotify commands.
7
 */
8
class GrowlNotifyBuilder extends BuilderAbstract
9
{
10
    /**
11
     * The notifier's path.
12
     *
13
     * @var string
14
     */
15
    protected $path = 'growlnotify';
16
17
    /**
18
     * Builds the growlnotify 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 9
    public function build($options)
24
    {
25 9
        $command = $this->path;
26
27 9
        if (isset($options['title'])) {
28 9
            $command .= " -t {$options['title']}";
29 9
        }
30 9
        if (isset($options['message'])) {
31 9
            $command .= " -m {$options['message']}";
32 9
        }
33 9
        if (isset($options['image'])) {
34 3
            $pathInfo = pathinfo($options['image']);
35 3
            if (isset($pathInfo['extension'])) {
36 3
                $command .= " --image {$options['image']}";
37 3
            } else {
38 3
                $command .= " -a {$options['image']}";
39
            }
40 3
        }
41 9
        if (isset($options['url'])) {
42 3
            $command .= " --url {$options['url']}";
43 3
        }
44 9
        if (isset($options['sticky']) && $options['sticky'] === true) {
45 6
            $command .= ' -s';
46 6
        }
47
48 9
        return $command;
49
    }
50
}
51