DefaultGenerator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 22
ccs 16
cts 16
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sortMetaData() 0 13 3
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SeoHelper\Generator;
6
7
use SeoHelper\MetaData\BaseMetaData;
8
use SeoHelper\Renderer\DefaultRenderer;
9
use SeoHelper\Renderer\FacebookRenderer;
10
use SeoHelper\Renderer\TwitterRenderer;
11
12 3
class DefaultGenerator extends BaseGenerator
13
{
14 3
    public function __construct(BaseMetaData $metaData)
0 ignored issues
show
Unused Code introduced by
The parameter $metaData is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

14
    public function __construct(/** @scrutinizer ignore-unused */ BaseMetaData $metaData)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
15 3
    {
16 3
        $this->addRenderer(new DefaultRenderer());
17 3
        $this->addRenderer(new FacebookRenderer());
18
        $this->addRenderer(new TwitterRenderer());
19 3
    }
20
21 3
    protected function sortMetaData(array $metaData): array
22 3
    {
23 3
        ksort($metaData);
24 3
        $metaDataToPrepend = ['title', 'description', 'keywords', 'robots'];
25 3
        $prependedMetaData = [];
26 3
        foreach ($metaDataToPrepend as $key) {
27
            if (!isset($metaData[$key])) {
28 3
                continue;
29 3
            }
30 1
            $prependedMetaData[$key] = $metaData[$key];
31 3
            unset($metaData[$key]);
32
        }
33
        return array_merge($prependedMetaData, $metaData);
34
    }
35
}
36