BasicSeoConfigurator::configure()   B
last analyzed

Complexity

Conditions 7
Paths 33

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
rs 7.551
cc 7
eloc 13
nc 33
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