| Conditions | 6 |
| Paths | 6 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 45 | 36 | public function whenValidate($model) |
|
| 46 | { |
||
| 47 | 36 | if (empty($this->when)) |
|
| 48 | { |
||
| 49 | 34 | return true; |
|
| 50 | } |
||
| 51 | 2 | if (is_string($this->when)) |
|
| 52 | { |
||
| 53 | 1 | $name = $this->when; |
|
| 54 | 1 | if ($model->$name) |
|
| 55 | { |
||
| 56 | 1 | return true; |
|
| 57 | } |
||
| 58 | } |
||
| 59 | 1 | elseif (is_array($this->when)) |
|
| 60 | { |
||
| 61 | 1 | $conditions = []; |
|
| 62 | 1 | foreach ($this->when as $name => $value) |
|
| 63 | { |
||
| 64 | 1 | $conditions[] = $model->$name === $value; |
|
| 65 | } |
||
| 66 | 1 | return count($conditions) === array_sum($conditions); |
|
| 67 | } |
||
| 68 | 1 | return false; |
|
| 69 | } |
||
| 70 | |||
| 72 |