We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 8 | class UserErrors extends UserFacingError |
||
| 9 | { |
||
| 10 | /** @var UserError[] */ |
||
| 11 | private $errors = []; |
||
| 12 | |||
| 13 | 2 | public function __construct(array $errors, $message = '', $code = 0, \Exception $previous = null) |
|
| 14 | { |
||
| 15 | 2 | $this->setErrors($errors); |
|
| 16 | 1 | parent::__construct($message, $code, $previous); |
|
| 17 | 1 | } |
|
| 18 | |||
| 19 | /** |
||
| 20 | * @param UserError[]|string[] $errors |
||
| 21 | */ |
||
| 22 | 2 | public function setErrors(array $errors) |
|
| 28 | |||
| 29 | /** |
||
| 30 | * @param string|UserError $error |
||
| 31 | * |
||
| 32 | * @return $this |
||
| 33 | */ |
||
| 34 | 2 | public function addError($error) |
|
| 35 | { |
||
| 36 | 2 | if (is_string($error)) { |
|
| 37 | 2 | $error = new UserError($error); |
|
| 38 | 2 | } elseif (!is_object($error) || !$error instanceof UserError) { |
|
| 39 | 1 | throw new \InvalidArgumentException(sprintf('Error must be string or instance of %s.', UserError::class)); |
|
| 40 | } |
||
| 41 | |||
| 42 | 2 | $this->errors[] = $error; |
|
| 43 | |||
| 44 | 2 | return $this; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return UserError[] |
||
| 49 | */ |
||
| 50 | 1 | public function getErrors() |
|
| 54 | } |
||
| 55 |