Completed
Push — 3.x ( 799626...732596 )
by Grégoire
04:11
created

TemplateRegistry   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTemplates() 0 4 1
A setTemplates() 0 4 1
A getTemplate() 0 6 2
A setTemplate() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\AdminBundle\Templating;
13
14
/**
15
 * @author Timo Bakx <[email protected]>
16
 */
17
final class TemplateRegistry implements MutableTemplateRegistryInterface
18
{
19
    private $templates = [];
20
21
    public function __construct(array $templates = [])
22
    {
23
        $this->templates = $templates;
24
    }
25
26
    public function getTemplates()
27
    {
28
        return $this->templates;
29
    }
30
31
    public function setTemplates(array $templates)
32
    {
33
        $this->templates = $templates;
34
    }
35
36
    public function getTemplate($name)
37
    {
38
        if (isset($this->templates[$name])) {
39
            return $this->templates[$name];
40
        }
41
    }
42
43
    public function setTemplate($name, $template)
44
    {
45
        $this->templates[$name] = $template;
46
    }
47
}
48