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

ProductionServer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A make() 0 4 1
A run() 0 4 1
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