1 | <?php |
||
7 | class InputParam implements ParamInterface |
||
8 | { |
||
9 | const TYPE_POST = 'POST'; |
||
10 | const TYPE_GET = 'GET'; |
||
11 | const TYPE_PUT = 'PUT'; |
||
12 | const TYPE_FILE = 'FILE'; |
||
13 | const TYPE_COOKIE = 'COOKIE'; |
||
14 | const TYPE_POST_RAW = 'POST_RAW'; |
||
15 | const TYPE_POST_JSON_KEY = 'POST_JSON_KEY'; |
||
16 | |||
17 | const OPTIONAL = false; |
||
18 | const REQUIRED = true; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $type; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $key; |
||
29 | |||
30 | /** |
||
31 | * @var bool |
||
32 | */ |
||
33 | private $required; |
||
34 | |||
35 | /** |
||
36 | * @var array|null |
||
37 | */ |
||
38 | private $availableValues; |
||
39 | |||
40 | /** |
||
41 | * @var bool |
||
42 | */ |
||
43 | private $multi; |
||
44 | |||
45 | 48 | public function __construct(string $type, string $key, bool $required = self::OPTIONAL, ?array $availableValues = null, bool $multi = false) |
|
53 | |||
54 | 9 | public function getType(): string |
|
58 | |||
59 | 21 | public function getKey(): string |
|
63 | |||
64 | 6 | public function isRequired(): bool |
|
68 | |||
69 | 6 | public function getAvailableValues(): ?array |
|
73 | |||
74 | 24 | public function isMulti(): bool |
|
78 | |||
79 | /** |
||
80 | * Check if actual value from environment is valid |
||
81 | * |
||
82 | * @return bool |
||
83 | * |
||
84 | * @throws Exception if actual InputParam has unsupported type |
||
85 | */ |
||
86 | 18 | public function isValid(): bool |
|
114 | |||
115 | /** |
||
116 | * Process environment variables like POST|GET|etc.. and return actual value |
||
117 | * |
||
118 | * @return mixed |
||
119 | * |
||
120 | * @throws Exception if actual InputParam has unsupported type |
||
121 | */ |
||
122 | 39 | public function getValue() |
|
177 | |||
178 | 3 | private function processMultiFileUploads($files) |
|
188 | } |
||
189 |