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

SeoGeneratorProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 8 2
A getAll() 0 4 1
A has() 0 4 1
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