Passed
Push — v2 ( 5c6a17...17236d )
by Brent
05:18
created

ProductionServer::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stitcher\Application;
4
5
class ProductionServer
6
{
7
    protected $html;
8
9 2
    public function __construct(string $rootDirectory, string $uri = null)
10
    {
11 2
        $uri = $uri ?? $_SERVER['SCRIPT_NAME'];
12 2
        $filename = ltrim($uri === '/' ? 'index.html' : "{$uri}.html", '/');
13
14 2
        $this->html = @file_get_contents("{$rootDirectory}/{$filename}");
15 2
    }
16
17 2
    public static function make(string $rootDirectory, string $uri = null): ProductionServer
18
    {
19 2
        return new self($rootDirectory, $uri);
20
    }
21
22 2
    public function run(): string
23
    {
24 2
        return $this->html;
25
    }
26
}
27