Conditions | 6 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function valid($value) |
||
21 | { |
||
22 | if ($value === 'max') { |
||
23 | return true; |
||
24 | } |
||
25 | |||
26 | if ($value === '^max') { |
||
27 | throw new NotImplementedException("Maximum size is not implemented."); |
||
28 | } |
||
29 | |||
30 | $this->upscale = str_starts_with($value, '^'); |
||
31 | |||
32 | if ($this->upscale) { |
||
33 | throw new NotImplementedException("Upscaling is not allowed."); |
||
34 | } |
||
35 | |||
36 | $isPercent = str_contains($value, 'pct:'); |
||
37 | |||
38 | if ($isPercent) { |
||
39 | return $this->isValidPercent($value); |
||
40 | } |
||
41 | |||
42 | $all_regex = implode('|', $this->regex); |
||
43 | if (preg_match('/' . $all_regex . '/', $value)) { |
||
44 | return true; |
||
45 | } |
||
46 | |||
47 | throw new BadRequestException("Size $value is invalid."); |
||
48 | } |
||
69 |