1 | <?php declare(strict_types = 1); |
||
2 | namespace Templado\Engine; |
||
3 | |||
4 | class FileName { |
||
5 | |||
6 | /** @var string */ |
||
7 | private $path; |
||
8 | |||
9 | 27 | public function __construct(string $path) { |
|
10 | 27 | $this->path = $path; |
|
11 | 27 | } |
|
12 | |||
13 | 3 | public function asString(): string { |
|
14 | 3 | return $this->path; |
|
15 | } |
||
16 | |||
17 | 3 | public function getMimeType(): string { |
|
18 | 3 | return \mime_content_type($this->path); |
|
19 | } |
||
20 | |||
21 | 3 | public function getName(): string { |
|
22 | 3 | return \pathinfo($this->path, \PATHINFO_FILENAME); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
23 | } |
||
24 | |||
25 | 6 | public function exists(): bool { |
|
26 | 6 | return \file_exists($this->path); |
|
27 | } |
||
28 | |||
29 | 6 | public function isFile(): bool { |
|
30 | 6 | return \is_file(\realpath($this->path)); |
|
31 | } |
||
32 | |||
33 | 6 | public function isReadable(): bool { |
|
34 | 6 | return \is_readable($this->path); |
|
35 | } |
||
36 | } |
||
37 |