| Conditions | 5 |
| Paths | 6 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 5 |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 9 | 22 | public function attach($rule, $data = null) |
|
| 10 | { |
||
| 11 | 22 | if ($this->contains($rule)) { |
|
| 12 | 1 | return; |
|
| 13 | } |
||
| 14 | 22 | if ($rule instanceof Rule\Required) { |
|
| 15 | 16 | $rules = array(); |
|
| 16 | 16 | foreach ($this as $r) { |
|
| 17 | 2 | $rules[] = $r; |
|
| 18 | 2 | $this->detach($r); |
|
| 19 | 16 | } |
|
| 20 | 16 | array_unshift($rules, $rule); |
|
| 21 | 16 | foreach ($rules as $r) { |
|
| 22 | 16 | parent::attach($r); |
|
| 23 | 16 | } |
|
| 24 | |||
| 25 | 16 | return; |
|
| 26 | } |
||
| 27 | |||
| 28 | 17 | return parent::attach($rule); |
|
| 29 | } |
||
| 30 | |||
| 38 |