Passed
Branch master (7c3f6c)
by Javi
02:38
created

IndexController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
namespace itsjavi\Flatdown\Controllers;
4
5
use itsjavi\Flatdown\Application;
6
use Psr\Http\Message\ServerRequestInterface;
7
8
class IndexController
9
{
10
    public function __invoke(ServerRequestInterface $req, array $params, Application $app)
11
    {
12
        $index_filename = $app->config('content_path') . '/index.md';
13
14
        if (file_exists($index_filename)) {
15
            return $app->get('markdown.page', [$index_filename]);
16
        } else {
17
            return $app->get('response', [302])->withHeader('location', $app->config('base_url') . '/_index');
18
        }
19
    }
20
21
    public function index(ServerRequestInterface $req, array $params, Application $app)
2 ignored issues
show
Unused Code introduced by
The parameter $req is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $data = ['files' => $app->get('markdown.files'), 'window_title' => 'Flatdown - Index'];
24
25
        return $app->get('templates')->render('index', $data);
26
    }
27
28
    public function about(ServerRequestInterface $req, array $params, Application $app)
2 ignored issues
show
Unused Code introduced by
The parameter $req is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30
        $index_filename = $app->config('base_path') . '/README.md';
31
32
        return $app->get('markdown.page', [$index_filename]);
33
    }
34
}
35