Completed
Push — master ( 1a117b...43f8bd )
by Mikael
11:04
created

FileBasedContentController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 34
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A catchAll() 0 17 2
1
<?php
2
3
namespace Anax\Controller;
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 Mikael Roos
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