| @@ 10-44 (lines=35) @@ | ||
| 7 | /** |
|
| 8 | * Simple Result object |
|
| 9 | */ |
|
| 10 | class Result |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var array |
|
| 14 | */ |
|
| 15 | private $errors = array(); |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @param $message |
|
| 19 | */ |
|
| 20 | public function addError($message) |
|
| 21 | { |
|
| 22 | if (!is_string($message)) { |
|
| 23 | throw InvalidArgumentException::invalidType('string', $message); |
|
| 24 | } |
|
| 25 | ||
| 26 | $this->errors[] = $message; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @return bool |
|
| 31 | */ |
|
| 32 | public function isValid() |
|
| 33 | { |
|
| 34 | return empty($this->errors); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @return array |
|
| 39 | */ |
|
| 40 | public function getErrors() |
|
| 41 | { |
|
| 42 | return $this->errors; |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 10-44 (lines=35) @@ | ||
| 7 | /** |
|
| 8 | * Simple Result object |
|
| 9 | */ |
|
| 10 | class Result |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var array |
|
| 14 | */ |
|
| 15 | private $errors = array(); |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @param $message |
|
| 19 | */ |
|
| 20 | public function addError($message) |
|
| 21 | { |
|
| 22 | if (!is_string($message)) { |
|
| 23 | throw InvalidArgumentException::invalidType('string', $message); |
|
| 24 | } |
|
| 25 | ||
| 26 | $this->errors[] = $message; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @return bool |
|
| 31 | */ |
|
| 32 | public function isValid() |
|
| 33 | { |
|
| 34 | return empty($this->errors); |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @return array |
|
| 39 | */ |
|
| 40 | public function getErrors() |
|
| 41 | { |
|
| 42 | return $this->errors; |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||