Conditions | 4 |
Paths | 3 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
45 | 10 | public function createResponse( $e, int $status = 500 ) : ResponseInterface |
|
46 | { |
||
47 | 10 | if (!$e instanceOf \Throwable) { |
|
48 | 2 | $msg = sprintf("Expected Throwable, got '%s'", gettype($e)); |
|
49 | 2 | throw new ResponderInvalidArgumentException($msg); |
|
50 | } |
||
51 | |||
52 | 8 | $exceptions = array($this->throwableToArray($e)); |
|
53 | 8 | while ($this->debug and $e = $e->getPrevious()) { |
|
54 | 2 | $exceptions[] = $this->throwableToArray($e); |
|
55 | } |
||
56 | |||
57 | $result = array( |
||
58 | 8 | 'errors' => $exceptions |
|
59 | ); |
||
60 | |||
61 | 8 | return $this->getResponder()->createResponse($result) |
|
62 | 8 | ->withStatus($status); |
|
63 | |||
64 | } |
||
65 | |||
82 |