ContentRenderer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 5
c 3
b 0
f 3
lcom 0
cbo 1
dl 0
loc 37
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 12 2
A renderContent() 0 8 1
A renderHeading() 0 7 1
A renderCopy() 0 4 1
1
<?php
2
namespace Axstrad\Bundle\ContentBundle\Renderer;
3
4
use Axstrad\Component\Content\Article;
5
6
/**
7
 * Axstrad\Bundle\ContentBundle\Renderer\ContentRenderer
8
 */
9
class ContentRenderer
10
{
11
    public function render($content)
12
    {
13
        $return = null;
14
15
        switch (true) {
16
            case $content instanceof Article:
17
                $return = $this->renderContent($content);
18
                break;
19
        }
20
21
        return $return;
22
    }
23
24
    public function renderContent(Article $article)
25
    {
26
        return sprintf(
27
            '<h1>%s</h1>%s',
28
            htmlspecialchars($article->getHeading()),
29
            $article->getCopy()
30
        );
31
    }
32
33
    public function renderHeading(Article $article)
34
    {
35
        return sprintf(
36
            '<h1>%s</h1>',
37
            htmlspecialchars($article->getHeading())
38
        );
39
    }
40
41
    public function renderCopy(Article $article)
42
    {
43
        return $article->getCopy();
44
    }
45
}
46