Completed
Branch master (0b86d9)
by Léo
02:17
created

SeoGeneratorProvider::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Leogout\Bundle\SeoBundle\Provider;
4
5
use Leogout\Bundle\SeoBundle\Seo\AbstractSeoGenerator;
6
7
/**
8
 * Description of SeoGeneratorProvider.
9
 *
10
 * @author: leogout
11
 */
12
class SeoGeneratorProvider
13
{
14
    /**
15
     * @var AbstractSeoGenerator[]
16
     */
17
    protected $generators = [];
18
19
    /**
20
     * SeoGeneratorProvider constructor.
21
     *
22
     * @param array $generators
23
     */
24
    public function __construct(array $generators)
25
    {
26
        $this->generators = $generators;
27
    }
28
29
    /**
30
     * @param string $alias
31
     *
32
     * @return AbstractSeoGenerator
33
     */
34
    public function get($alias)
35
    {
36
        if (!isset($this->generators[$alias])) {
37
            throw new \InvalidArgumentException(sprintf('The SEO generator with alias "%s" is not defined.', $alias));
38
        }
39
40
        return $this->generators[$alias];
41
    }
42
43
    /**
44
     * @return AbstractSeoGenerator[]
45
     */
46
    public function getAll()
47
    {
48
        return $this->generators;
49
    }
50
51
    /**
52
     * @param $alias
53
     *
54
     * @return bool
55
     */
56
    public function has($alias)
57
    {
58
        return isset($this->generators[$alias]);
59
    }
60
}
61