Http::notFound()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 21
ccs 0
cts 6
cp 0
crap 2
rs 9.584
c 0
b 0
f 0
1
<?php
2
3
namespace Stitcher\Exception;
4
5
use Pageon\Config;
6
use Stitcher\File;
7
8
class Http extends StitcherException
9
{
10
    protected $statusCode;
11
12
    public function __construct(string $title, string $body, int $statusCode = 500)
13
    {
14
        parent::__construct($title, $body);
15
16
        $this->statusCode = $statusCode;
17
    }
18
19
    public static function notFound(string $uri): Http
20
    {
21
        $siteConfigurationFile = File::relativePath(Config::get('configurationFile'));
22
23
        $body = <<<MD
24
The URI `$uri` could not be find. 
25
26
Please check in `$siteConfigurationFile` for static pages or `./src/routes.php` for dynamic routes.
27
28
```
29
$uri:
30
    template: # ...
31
    variables: 
32
        # ...
33
    config:
34
        # ...
35
```
36
MD;
37
38
        return new self("`{$uri}` was not found.", $body, 404);
39
    }
40
41
    public function statusCode(): int
42
    {
43
        return $this->statusCode;
44
    }
45
}
46