TwitterRenderer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 70%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 11
c 3
b 0
f 0
dl 0
loc 18
ccs 7
cts 10
cp 0.7
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A initPreprocessors() 0 12 1
1
<?php
2
3
namespace SeoHelper\Renderer;
4
5
class TwitterRenderer extends AbstractRenderer
6
{
7
    protected array $types = [
8
        'twitter' => '<meta property="{$key}" content="{$value}">',
9
    ];
10
11 4
    protected function initPreprocessors(): void
12
    {
13 8
        $this->setPreprocessor('twitter:title', function ($value) {
14 3
            return htmlspecialchars(strip_tags(implode(' | ', array_reverse($value))));
15 12
        });
16 8
        $this->setPreprocessor('twitter:description', function ($value) {
17 3
            return htmlspecialchars(strip_tags(implode(' ', $value)));
18 12
        });
19
        $this->setPreprocessor('twitter:url', function ($value) {
20
            return array_map(function ($val) {
21
                return htmlspecialchars(strip_tags($val));
22
            }, $value);
23 4
        });
24 4
    }
25
}
26