FileBasedContentController::catchAll()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 9
cp 0
rs 9.7
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
3
namespace Anax\Content;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
use Anax\Route\Exception\NotFoundException;
8
9
/**
10
 * A controller for flat file markdown content.
11
 */
12
class FileBasedContentController implements ContainerInjectableInterface
13
{
14
    use ContainerInjectableTrait;
15
16
17
18
    /**
19
     * Render a page using flat file content.
20
     *
21
     * @param array $args as a variadic to catch all arguments.
22
     *
23
     * @return mixed as null when flat file is not found and otherwise a
24
     *               complete response object with content to render.
25
     *
26
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
27
     */
28
    public function catchAll(...$args)
0 ignored issues
show
Unused Code introduced by
The parameter $args 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
        $content = $this->di->get("content");
31
        $page = $this->di->get("page");
32
33
        try {
34
            $fileContent = $content->contentForRoute();
35
        } catch(NotFoundException $e) {
36
            return false;
37
        }
38
39
        foreach ($fileContent->views as $view) {
40
            $page->add($view);
41
        }
42
43
        return $page->render($fileContent->frontmatter);
44
    }
45
}
46