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

BasicSeoConfigurator::getConfig()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
3
namespace Leogout\Bundle\SeoBundle\Seo\Basic;
4
5
use Leogout\Bundle\SeoBundle\Exception\InvalidSeoGeneratorException;
6
use Leogout\Bundle\SeoBundle\Seo\AbstractSeoConfigurator;
7
use Leogout\Bundle\SeoBundle\Seo\AbstractSeoGenerator;
8
9
/**
10
 * Description of BasicSeoConfigurator.
11
 *
12
 * @author: leogout
13
 */
14
class BasicSeoConfigurator extends AbstractSeoConfigurator
15
{
16
    /**
17
     * @param AbstractSeoGenerator $generator
18
     */
19
    public function configure(AbstractSeoGenerator $generator)
20
    {
21
        if (!($generator instanceof BasicSeoGenerator)) {
22
            throw new InvalidSeoGeneratorException(__CLASS__, BasicSeoGenerator::class, get_class($generator));
23
        }
24
        if (null !== $title = $this->getConfig('title')) {
25
            $generator->setTitle($title);
26
        }
27
        if (null !== $description = $this->getConfig('description')) {
28
            $generator->setDescription($description);
29
        }
30
        if (null !== $keywords = $this->getConfig('keywords')) {
31
            $generator->setKeywords($keywords);
32
        }
33
        if (null !== $robots = $this->getConfig('robots')) {
34
            $generator->setRobots($robots['index'], $robots['follow']);
35
        }
36
        if (null !== $canonical = $this->getConfig('canonical')) {
37
            $generator->setCanonical($canonical);
38
        }
39
    }
40
}
41