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

ErrorController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 46.15%

Importance

Changes 0
Metric Value
wmc 4
eloc 9
dl 0
loc 25
ccs 6
cts 13
cp 0.4615
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A errorAction() 0 10 1
A notFoundAction() 0 3 1
A notAuthorisedAction() 0 1 1
A __construct() 0 3 1
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
}