Total Complexity | 5 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 81.82% |
Changes | 0 |
1 | <?php |
||
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() |
||
59 | } |
||
60 | } |
||
61 |