| Total Complexity | 6 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | final class Notification implements Countable, IteratorAggregate |
||
| 21 | { |
||
| 22 | private $errors = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Adds new error to the notification. |
||
| 26 | * |
||
| 27 | * @param string $message |
||
| 28 | * @param array $context |
||
| 29 | */ |
||
| 30 | 1 | public function addError(string $message, array $context = []): void |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Returns whether the notification has any errors. |
||
| 37 | * |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | 2 | public function hasErrors(): bool |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Flushes the notification errors. |
||
| 47 | */ |
||
| 48 | 1 | public function flushErrors(): array |
|
| 49 | { |
||
| 50 | 1 | $errors = $this->errors; |
|
| 51 | 1 | $this->errors = []; |
|
| 52 | |||
| 53 | 1 | return $errors; |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return array |
||
| 58 | */ |
||
| 59 | 1 | public function getErrorMessages(): array |
|
| 66 | ); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Counts the errors. |
||
| 71 | * |
||
| 72 | * @inheritdoc |
||
| 73 | */ |
||
| 74 | 2 | public function count(): int |
|
| 75 | { |
||
| 76 | 2 | return count($this->errors); |
|
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Builds the iterator by errors. |
||
| 81 | * |
||
| 82 | * @inheritdoc |
||
| 83 | * |
||
| 84 | * @return Traversable|Error[] |
||
| 85 | */ |
||
| 86 | 1 | public function getIterator(): Traversable |
|
| 89 | } |
||
| 90 | } |
||
| 91 |