Completed
Push — master ( d14457...da0e1e )
by Derek Stephen
25:25 queued 19:55
created

ErrorController::errorAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Controller;
4
5
use Bone\Mvc\Controller;
6
use Exception;
7
use Psr\Http\Message\ServerRequestInterface;
8
9
class ErrorController extends BaseController
10
{
11 1
    public function __construct(ServerRequestInterface $request)
12
    {
13 1
        parent::__construct($request);
14 1
    }
15
16
    public function errorAction()
17
    {
18
        /** @var Exception $e */
19
        $e = $this->getParam('error');
20
        $responseArray = [
21
            'code' => $e->getCode(),
22
            'message' => $e->getMessage(),
23
            'trace' => $e->getTrace(),
24
        ];
25
        $this->sendJsonResponse($responseArray, $e->getCode());
26
    }
27
28 1
    public function notFoundAction()
29
    {
30 1
        $this->sendJsonResponse(['message' => 'Resource not found'], 404);
31 1
    }
32
33
    public function notAuthorisedAction(){}
34
}