| Conditions | 5 |
| Paths | 10 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | 1 | public function validate(array $values) : bool |
|
| 33 | { |
||
| 34 | 1 | $isEmpty = true; |
|
| 35 | |||
| 36 | 1 | foreach ($values as $key => $data) { |
|
| 37 | 1 | if (is_string($data)) { |
|
| 38 | 1 | $data = trim($data); |
|
| 39 | } |
||
| 40 | |||
| 41 | 1 | if (!empty($data)) { |
|
| 42 | 1 | $isEmpty = false; |
|
| 43 | 1 | $this->validData[$key] = $data; |
|
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | 1 | if ($isEmpty) { |
|
| 48 | 1 | $this->errors[] = 'This field is mandatory and cannot be empty'; |
|
| 49 | 1 | return false; |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | return true; |
|
| 53 | } |
||
| 54 | |||
| 75 |