StaticFileResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 2
1
<?php
2
namespace JsLocalization\Http\Responses;
3
4
use App;
5
use DateTime;
6
use Exception;
7
use Illuminate\Http\Response;
8
use Illuminate\Support\Facades\File;
9
10
class StaticFileResponse extends Response
11
{
12 3
    public function __construct($filePath)
13
    {
14 3
        parent::__construct();
15
16 3
        if (!File::isFile($filePath)) {
17 1
            throw new Exception("Cannot read file: $filePath");
18
        }
19
20 2
        $fileContent = file_get_contents($filePath);
21 2
        $this->setContent($fileContent);
22
23 2
        $lastModified = new DateTime();
24 2
        $lastModified->setTimestamp( File::lastModified($filePath) );
25
26 2
        $this->setLastModified($lastModified);
27
28 2
        $this->isNotModified(App::make('request'));
29
    }
30
}