Completed
Pull Request — master (#5032)
by Grégoire
03:41
created

TemplateRegistry::getTemplate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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