Conditions | 4 |
Paths | 6 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.3244 |
Changes | 0 |
1 | <?php |
||
34 | 2 | protected function handleStaticRoute(): ?Response |
|
35 | { |
||
36 | 2 | $path = $this->path ?? $this->getCurrentPath(); |
|
37 | |||
38 | 2 | $this->partialParse->setFilter($path); |
|
39 | |||
40 | try { |
||
41 | 2 | $this->partialParse->execute(); |
|
42 | |||
43 | 2 | $filename = ltrim($path === '/' ? 'index.html' : "{$path}.html", '/'); |
|
44 | |||
45 | 2 | $body = @file_get_contents("{$this->rootDirectory}/{$filename}"); |
|
46 | |||
47 | 2 | if (! $body) { |
|
48 | return null; |
||
49 | } |
||
50 | |||
51 | 2 | return new Response(200, [], $body); |
|
52 | } catch (ResourceNotFoundException $e) { |
||
53 | return null; |
||
54 | } |
||
55 | } |
||
56 | } |
||
57 |