Passed
Push — master ( 22bc6e...3fff97 )
by Dev
13:34
created

PageMainContentManager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace PiedWeb\CMSBundle\Service\PageMainContentManager;
4
5
use Knp\Bundle\MarkdownBundle\MarkdownParserInterface;
6
use PiedWeb\CMSBundle\Entity\PageInterface;
7
use PiedWeb\CMSBundle\Entity\PageMainContentType;
8
use PiedWeb\CMSBundle\Service\App;
9
use Twig\Environment as Twig;
10
11
class PageMainContentManager
12
{
13
    protected $twig;
14
    protected $app;
15
    protected $markdownParser;
16
    protected $page;
17
18
    public function __construct(
19
        App $app,
20
        Twig $twig,
21
        MarkdownParserInterface $markdownParser
22
    ) {
23
        $this->app = $app;
24
        $this->twig = $twig;
25
        $this->markdownParser = $markdownParser;
26
    }
27
28
    public function manage(PageInterface $page): MainContentManagerInterface
29
    {
30
        $this->page = $page;
31
32
        if (PageMainContentType::MARKDOWN === $page->getMainContentType()) {
33
            return new Markdown($this->app, $this->twig, $page, $this->markdownParser);
34
        }
35
36
        return new Raw($this->app, $this->twig, $page);
37
    }
38
}
39