ContentRenderer::renderCopy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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