FacebookRenderer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 70%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 19
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 FacebookRenderer extends AbstractRenderer
6
{
7
    protected array $types = [
8
        'og' => '<meta property="{$key}" content="{$value}">',
9
        'fb' => '<meta property="{$key}" content="{$value}">',
10
    ];
11
12 4
    protected function initPreprocessors(): void
13
    {
14 8
        $this->setPreprocessor('og:title', function ($value) {
15 3
            return htmlspecialchars(strip_tags(implode(' | ', array_reverse($value))));
16 12
        });
17 8
        $this->setPreprocessor('og:description', function ($value) {
18 3
            return htmlspecialchars(strip_tags(implode(' ', $value)));
19 12
        });
20
        $this->setPreprocessor('og:url', function ($value) {
21
            return array_map(function ($val) {
22
                return htmlspecialchars(strip_tags($val));
23
            }, $value);
24 4
        });
25 4
    }
26
}
27