1 | <?php |
||
16 | class FilesCountValidator extends BaseObject implements ValidatorInterface |
||
17 | { |
||
18 | use ServerVariableTrait; |
||
19 | |||
20 | /** |
||
21 | * Error message |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | public $message = 'Maximum number of files exceeded'; |
||
26 | |||
27 | /** |
||
28 | * Minimum file size |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | public $maxCountOfFiles; |
||
33 | |||
34 | /** |
||
35 | * File upload path |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | public $uploadDir; |
||
40 | |||
41 | /** |
||
42 | * Validate file |
||
43 | * |
||
44 | * @param UploadedFile $file |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function validate(UploadedFile &$file): bool |
||
60 | |||
61 | /** |
||
62 | * Count file objects |
||
63 | * |
||
64 | * @return int |
||
65 | */ |
||
66 | protected function countFileObjects(): int |
||
70 | |||
71 | /** |
||
72 | * Get file objects |
||
73 | * |
||
74 | * @param string $iterationMethod |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | protected function getFileObjects(string $iterationMethod = 'get_file_object'): array |
||
91 | |||
92 | /** |
||
93 | * Get upload path |
||
94 | * |
||
95 | * @param null|string $fileName |
||
96 | * @param null|string $version |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | protected function getUploadDir(?string $fileName = null, ?string $version = null) |
||
111 | } |
||
112 |