Total Complexity | 12 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Coverage | 53.56% |
Changes | 0 |
1 | <?php |
||
5 | class ResponseFromCache extends Response |
||
6 | { |
||
7 | /** @var string */ |
||
8 | protected $url; |
||
9 | |||
10 | /** |
||
11 | * @param string $filePath |
||
12 | * @param mixed $headers could be a string (the separator between headers and content or FALSE |
||
13 | */ |
||
14 | 3 | public function __construct( |
|
15 | string $filePathOrContent, |
||
16 | ?string $url = null, |
||
17 | array $info = [], |
||
18 | $headers = PHP_EOL.PHP_EOL |
||
19 | ) { |
||
20 | 3 | $content = file_exists($filePathOrContent) ? file_get_contents($filePathOrContent) : $filePathOrContent; |
|
21 | |||
22 | 3 | if (!$content) { |
|
23 | throw new \Exception($filePath.' doesn\'t exist'); |
||
|
|||
24 | } |
||
25 | |||
26 | 3 | if (false !== $headers) { |
|
27 | 3 | list($this->headers, $this->content) = explode($headers, $content, 2); |
|
28 | } else { |
||
29 | $this->content = $content; |
||
30 | } |
||
31 | |||
32 | 3 | $this->info = $info; |
|
33 | 3 | $this->url = $url; |
|
34 | 3 | } |
|
35 | |||
36 | 3 | public function getRequest() |
|
37 | { |
||
38 | 3 | return null; |
|
39 | } |
||
40 | |||
41 | public function getUrl() |
||
44 | } |
||
45 | |||
46 | public function getEffectiveUrl() |
||
47 | { |
||
48 | return $this->url; |
||
49 | } |
||
50 | |||
51 | public function getStatusCode() |
||
61 | } |
||
62 | |||
63 | 3 | public function getContentType() |
|
73 | } |
||
74 | } |
||
75 |