FacebookRenderer::initPreprocessors()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1.027

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
ccs 7
cts 10
cp 0.7
crap 1.027
rs 10
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