WatchRecord   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 5
eloc 9
c 0
b 0
f 0
dl 0
loc 54
ccs 9
cts 11
cp 0.8182
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A getPath() 0 3 1
A __construct() 0 3 1
A eventExists() 0 3 1
A isFile() 0 3 1
1
<?php
2
3
namespace App\Libraries\WatchRecord;
4
5
abstract class WatchRecord implements WatchRecordInterface
6
{
7
    /**
8
     * Array of the occurred events.
9
     *
10
     * @var array
11
     */
12
    protected $events;
13
14
    /**
15
     * Full path of the file/directory on which the event occurred.
16
     *
17
     * @var string
18
     */
19
    protected $path;
20
21
    /**
22
     * The input of the watch record.
23
     * For example, an inotifywatch record should have an input similar to
24
     * "DELETE /var/www/media/song.mp3".
25
     *
26
     * @var string
27
     */
28
    protected $input;
29
30
    /**
31
     * @param string $input The output from a watcher command (which is an input for our script)
32
     */
33 3
    public function __construct(string $input)
34
    {
35 3
        $this->input = $input;
36 3
    }
37
38 3
    public function isFile(): bool
39
    {
40 3
        return !$this->isDirectory();
41
    }
42
43
    /**
44
     * Check if a given event name exists in the event array.
45
     */
46 3
    protected function eventExists(string $event): bool
47
    {
48 3
        return in_array($event, $this->events, true);
49
    }
50
51 3
    public function getPath(): string
52
    {
53 3
        return $this->path;
54
    }
55
56
    public function __toString()
57
    {
58
        return $this->input;
59
    }
60
}
61