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

Http::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
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