Conditions | 8 |
Paths | 6 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 2 |
CRAP Score | 10.3696 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
29 | protected function getValueSize($value) |
||
30 | { |
||
31 | if (null !== $attribute = $this->getAttribute()) { |
||
|
|||
32 | if (is_numeric($value) && ($attribute->hasRule('integer') || $attribute->hasRule('numeric') || $attribute->hasRule('decimal'))) { |
||
33 | 2 | $value = (float) $value; |
|
34 | } |
||
35 | } |
||
36 | |||
37 | $size = match (true) { |
||
38 | is_int($value) || is_float($value) => $value, |
||
39 | is_string($value) => mb_strlen($value, 'UTF-8'), |
||
40 | $this->isUploadedFileValue($value) => $value['size'], |
||
41 | is_array($value) => count($value), |
||
42 | $this->isValidFileInstance($value) => $value->getSize() / 1024, |
||
43 | $value instanceof Countable => $value->count(), |
||
44 | default => false |
||
45 | }; |
||
46 | |||
47 | 4 | return $size === false ? false : (float) $size; |
|
48 | } |
||
50 |