| Total Complexity | 6 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 46.67% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class BadPayloadException extends \RuntimeException |
||
| 6 | { |
||
| 7 | private $payload; |
||
| 8 | |||
| 9 | 1 | public function __construct($payload, $message = '', $code = 0, \Throwable $previous = null) |
|
| 14 | 1 | } |
|
| 15 | |||
| 16 | public function getPayload() |
||
| 17 | { |
||
| 18 | return $this->payload; |
||
| 19 | } |
||
| 20 | |||
| 21 | public static function unexpectedType($payload, string $expectedType, string $class): self |
||
| 22 | { |
||
| 23 | $message = sprintf('%s expects payload to be %s, %s given.', |
||
| 24 | $class, |
||
| 25 | $expectedType, |
||
| 26 | is_object($payload) ? get_class($payload) : gettype($payload) |
||
| 27 | ); |
||
| 28 | |||
| 29 | return new self($payload, $message); |
||
| 30 | } |
||
| 31 | |||
| 32 | 1 | public static function missingOrEmptyKeyValue($payload, string $key, string $type, string $class): self |
|
| 37 | } |
||
| 38 | } |
||
| 39 |