| Total Complexity | 6 |
| Total Lines | 74 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class FailureCollection implements FailureCollectionInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * |
||
| 17 | * Array of failed messages for fields. |
||
| 18 | * |
||
| 19 | * @var array |
||
| 20 | * |
||
| 21 | */ |
||
| 22 | protected $messages = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * |
||
| 26 | * Is the failure collection empty? |
||
| 27 | * |
||
| 28 | * @return bool |
||
| 29 | * |
||
| 30 | */ |
||
| 31 | public function isEmpty() |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * |
||
| 38 | * Adds an additional failure on a field. |
||
| 39 | * |
||
| 40 | * @param string $field The field that failed. |
||
| 41 | * |
||
| 42 | * @param string|array $messages The failure messages. |
||
| 43 | * |
||
| 44 | * @return null |
||
| 45 | * |
||
| 46 | */ |
||
| 47 | public function addMessagesForField($field, $messages) |
||
| 48 | { |
||
| 49 | if (! isset($this->messages[$field])) { |
||
| 50 | $this->messages[$field] = []; |
||
| 51 | } |
||
| 52 | |||
| 53 | $this->messages[$field] = array_merge( |
||
| 54 | $this->messages[$field], |
||
| 55 | (array) $messages |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * |
||
| 61 | * Returns all failure messages for all fields. |
||
| 62 | * |
||
| 63 | * @return array |
||
| 64 | * |
||
| 65 | */ |
||
| 66 | public function getMessages() |
||
| 67 | { |
||
| 68 | return $this->messages; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * |
||
| 73 | * Returns all failure messages for one field. |
||
| 74 | * |
||
| 75 | * @param string $field The field name. |
||
| 76 | * |
||
| 77 | * @return array |
||
| 78 | * |
||
| 79 | */ |
||
| 80 | public function getMessagesForField($field) |
||
| 87 | } |
||
| 88 | } |
||
| 89 |