Http   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A notFound() 0 21 1
A statusCode() 0 4 1
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