Completed
Push — master ( 43f8bd...20bf29 )
by Mikael
43:28 queued 03:45
created

FileBasedContentController::catchAll()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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