Completed
Push — master ( 066784...351105 )
by Joao Gilberto
02:29
created

WhoopsHeaderTrait   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 9
c 2
b 1
f 1
lcom 0
cbo 0
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B setProperHeader() 0 20 9
1
<?php
2
3
namespace ByJG\RestServer\Whoops;
4
5
trait WhoopsHeaderTrait
6
{
7
    public function setProperHeader(\Exception $exception)
8
    {
9
        if ($exception instanceof \ByJG\RestServer\Exception\Error401Exception) {
10
            header('HTTP/1.0 401 Unathorized', true, 401);
11
        } elseif ($exception instanceof \ByJG\RestServer\Exception\Error402Exception) {
12
            header('HTTP/1.0 402 Payment Required', true, 402);
13
        } elseif ($exception instanceof \ByJG\RestServer\Exception\Error403Exception) {
14
            header('HTTP/1.0 403 Forbidden', true, 403);
15
        } elseif ($exception instanceof \ByJG\RestServer\Exception\Error404Exception) {
16
            header('HTTP/1.0 404 Not Found', true, 404);
17
        } elseif ($exception instanceof \ByJG\RestServer\Exception\ClassNotFoundException) {
18
            header('HTTP/1.0 404 Not Found', true, 404);
19
        } elseif ($exception instanceof \ByJG\RestServer\Exception\Error405Exception) {
20
            header('HTTP/1.0 405 Method not allowed', true, 405);
21
        } elseif ($exception instanceof \ByJG\RestServer\Exception\Error501Exception) {
22
            header('HTTP/1.0 501 Not Implemented', true, 501);
23
        } elseif ($exception instanceof \BadMethodCallException) {
24
            header('HTTP/1.0 501 Not Implemented', true, 501);
25
        }
26
    }
27
}
28