Passed
Push — develop ( 05b597...ba19c4 )
by Brent
02:38 queued 15s
created

Http   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 45
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B notFound() 0 28 1
A statusCode() 0 4 1
1
<?php
2
3
namespace Stitcher\Exception;
4
5
class Http extends StitcherException
6
{
7
    protected $statusCode;
8
9
    public function __construct(string $title, string $body, int $statusCode = 500)
10
    {
11
        parent::__construct($title, $body);
12
13
        $this->statusCode = $statusCode;
14
    }
15
16
    public static function notFound(string $uri): Http
17
    {
18
        $body = <<<MD
19
The URI `$uri` could not be find. 
20
21
Please check in `site.yaml` or `routes.php`.
22
23
```
24
developmentServer:
25
    class: Stitcher\Application\DevelopmentServer
26
    arguments:
27
        - '%publicDirectory%'
28
        - '@parsePartial'
29
    calls:
30
        - ['setRouter', ['@router']]
31
        - ['setMarkdownParser', ['@markdownParser']]
32
productionServer:
33
    class: Stitcher\Application\ProductionServer
34
    arguments:
35
        - '%publicDirectory%'
36
    calls:
37
        - ['setRouter', ['@router']]
38
        - ['setMarkdownParser', ['@markdownParser']]
39
```
40
MD;
41
42
        return new self("`{$uri}` was not found.", $body, 404);
43
    }
44
45
    public function statusCode(): int
46
    {
47
        return $this->statusCode;
48
    }
49
}
50