Total Complexity | 8 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class Requester |
||
6 | { |
||
7 | protected $basePath; |
||
8 | |||
9 | /** |
||
10 | * Create a new instance |
||
11 | * |
||
12 | * @return self |
||
13 | */ |
||
14 | public static function make() |
||
15 | { |
||
16 | return new static(); |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * Set the base path |
||
21 | * |
||
22 | * @param $path |
||
23 | * @return $this |
||
24 | */ |
||
25 | public function setBasePath($path) |
||
26 | { |
||
27 | $this->basePath = $path; |
||
28 | if (!ends_with($this->basePath, DIRECTORY_SEPARATOR)) { |
||
29 | $this->basePath .= DIRECTORY_SEPARATOR; |
||
30 | } |
||
31 | |||
32 | return $this; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Determine if the given file is exists |
||
37 | * |
||
38 | * @param string $file |
||
39 | * @return boolean |
||
40 | */ |
||
41 | public function exists(string $file) : bool |
||
42 | { |
||
43 | return file_exists($this->path($file)); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Get the path for the given file |
||
48 | * |
||
49 | * @param string $file |
||
50 | * @return string |
||
51 | */ |
||
52 | public function path(string $file) |
||
53 | { |
||
54 | return $this->basePath.$file; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Get all files in the specified directory |
||
59 | * |
||
60 | * @param $path |
||
61 | * @return array |
||
62 | */ |
||
63 | public function getFiles($path) |
||
74 | } |
||
75 | } |
||
76 |