| Total Complexity | 3 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class InvalidArgumentException extends ValidationException |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var string |
||
| 9 | */ |
||
| 10 | protected $expectedType; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $actualType; |
||
| 16 | |||
| 17 | /** |
||
|
|
|||
| 18 | * InvalidArgumentException constructor. |
||
| 19 | * |
||
| 20 | * @param $field |
||
| 21 | * @param string $expectedType |
||
| 22 | * @param mixed $actual |
||
| 23 | */ |
||
| 24 | 9 | public function __construct($field, $expectedType, $actual) |
|
| 25 | { |
||
| 26 | 9 | $this->expectedType = $expectedType; |
|
| 27 | 9 | $this->actualType = gettype($actual); |
|
| 28 | 9 | $message = sprintf('Expected %s but found %s.', $this->expectedType, $this->actualType); |
|
| 29 | $error = [ |
||
| 30 | 9 | 'type' => 'invalid_argument', |
|
| 31 | 9 | 'extra' => [$this->expectedType, $this->actualType], |
|
| 32 | 9 | 'field' => $field, |
|
| 33 | 9 | 'message' => $message, |
|
| 34 | ]; |
||
| 35 | 9 | parent::__construct([$error], $message); |
|
| 36 | 9 | } |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @return string |
||
| 40 | */ |
||
| 41 | 1 | public function getExpectedType() |
|
| 42 | { |
||
| 43 | 1 | return $this->expectedType; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | 1 | public function getActualType() |
|
| 52 | } |
||
| 53 | } |
||
| 54 |