1 | <?php |
||
15 | class FileName |
||
16 | { |
||
17 | /** |
||
18 | * @var int|null |
||
19 | */ |
||
20 | protected $length; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $uploadDir; |
||
26 | |||
27 | /** |
||
28 | * FileName constructor. |
||
29 | * |
||
30 | * @param string $uploadDir |
||
31 | * @param int|null $length |
||
32 | */ |
||
33 | public function __construct(string $uploadDir, ?int $length) |
||
38 | |||
39 | /** |
||
40 | * Get file name |
||
41 | * |
||
42 | * @param UploadedFile $uploadedFile |
||
43 | * |
||
44 | * @return mixed |
||
45 | */ |
||
46 | public function getFileName(UploadedFile $uploadedFile) |
||
52 | |||
53 | /** |
||
54 | * Trim file name |
||
55 | * |
||
56 | * @param UploadedFile $uploadedFile |
||
57 | * |
||
58 | * @return bool|mixed|string |
||
59 | * |
||
60 | * @throws NotSupportedException |
||
61 | */ |
||
62 | protected function trimFileName(UploadedFile $uploadedFile) |
||
81 | |||
82 | /** |
||
83 | * Get unique file name |
||
84 | * |
||
85 | * @param UploadedFile $uploadedFile |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | protected function getUniqueFileName(UploadedFile $uploadedFile) |
||
107 | |||
108 | /** |
||
109 | * @param $name |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | protected function upCountName($name) |
||
122 | |||
123 | /** |
||
124 | * Get file base name |
||
125 | * |
||
126 | * @param string $filePath |
||
127 | * @param null|string $suffix |
||
128 | * |
||
129 | * @return bool|string |
||
130 | */ |
||
131 | protected function getBasename(string $filePath, ?string $suffix = null) |
||
137 | |||
138 | /** |
||
139 | * Get file size |
||
140 | * |
||
141 | * @param string $filePath |
||
142 | * @param bool $clearStatCache |
||
143 | * |
||
144 | * @return float |
||
145 | */ |
||
146 | protected function getFileSize(string $filePath, bool $clearStatCache = false) |
||
158 | |||
159 | /** |
||
160 | * Get upload path |
||
161 | * |
||
162 | * @param null|string $fileName |
||
163 | * @param null|string $version |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | protected function getUploadDir(?string $fileName = null, ?string $version = null) |
||
178 | } |
||
179 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: