1 | <?php |
||
13 | class Filesystem extends AbstractChecker |
||
14 | 4 | { |
|
15 | /** |
||
16 | 4 | * @var string |
|
17 | */ |
||
18 | 4 | protected $target = 'path'; |
|
19 | 3 | ||
20 | /** |
||
21 | * @param string $path |
||
22 | 3 | * @param boolean $expectExists |
|
23 | * @param array $task |
||
24 | 3 | * |
|
25 | * @throws FailException |
||
26 | * @throws SuccessException |
||
27 | 2 | */ |
|
28 | protected function testExists($path, $expectExists, array $task) |
||
29 | 2 | { |
|
30 | 1 | $exists = is_file($path) || is_dir($path); |
|
31 | |||
32 | if ($exists === $expectExists) { |
||
33 | 1 | throw new SuccessException('Ok', $task); |
|
34 | } |
||
35 | 1 | ||
36 | $msg = $expectExists ? "Path '{$path}' is not exists'" : "Path '{$path}' is exists"; |
||
37 | |||
38 | throw new FailException($msg, $task); |
||
39 | 2 | } |
|
40 | |||
41 | 2 | /** |
|
42 | 1 | * @param string $path |
|
43 | * @param boolean $expectFile |
||
44 | * @param array $task |
||
45 | 1 | * |
|
46 | * @throws FailException |
||
47 | 1 | * @throws SuccessException |
|
48 | */ |
||
49 | protected function testFile($path, $expectFile, array $task) |
||
59 | |||
60 | /** |
||
61 | 2 | * @param string $path |
|
62 | * @param boolean $expectFolder |
||
63 | 2 | * @param array $task |
|
64 | 1 | * |
|
65 | * @throws FailException |
||
66 | * @throws SuccessException |
||
67 | 1 | */ |
|
68 | protected function testFolder($path, $expectFolder, array $task) |
||
78 | |||
79 | /** |
||
80 | 1 | * @param string $path |
|
81 | * @param boolean $expectWritable |
||
82 | 1 | * @param array $task |
|
83 | * |
||
84 | * @throws FailException |
||
85 | * @throws SuccessException |
||
86 | */ |
||
87 | protected function testWritable($path, $expectWritable, array $task) |
||
97 | |||
98 | /** |
||
99 | * @param string $path |
||
100 | * @param boolean $expectReadable |
||
101 | * @param array $task |
||
102 | * |
||
103 | * @throws FailException |
||
104 | * @throws SuccessException |
||
105 | */ |
||
106 | protected function testReadable($path, $expectReadable, array $task) |
||
116 | |||
117 | /** |
||
118 | * @param string $path |
||
119 | * @param boolean $expectChmod |
||
120 | * @param array $task |
||
121 | * |
||
122 | * @throws FailException |
||
123 | * @throws SuccessException |
||
124 | */ |
||
125 | protected function testChmod($path, $expectChmod, array $task) |
||
137 | |||
138 | /** |
||
139 | * @param string $path |
||
140 | * @param string $find |
||
141 | * @param array $task |
||
142 | * |
||
143 | * @throws FailException |
||
144 | * @throws SuccessException |
||
145 | */ |
||
146 | protected function testContain($path, $find, array $task) |
||
158 | } |
||
159 |