TargetsStyleLoaderTagHook   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 22
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A targetStyleLoaderTagHook() 0 10 1
A getStyleLoaderTagCallback() 0 4 1
1
<?php
2
3
namespace Leonidas\Hooks;
4
5
use Closure;
6
7
trait TargetsStyleLoaderTagHook
8
{
9
    protected function targetStyleLoaderTagHook()
10
    {
11
        add_filter(
12
            'style_loader_tag',
13
            $this->getStyleLoaderTagCallback(),
14
            10,
15
            PHP_INT_MAX
16
        );
17
18
        return $this;
19
    }
20
21
    protected function getStyleLoaderTagCallback(): Closure
22
    {
23
        return function (string $tag, string $handle, string $href, string $media) {
24
            return $this->filterStyleLoaderTag($tag, $handle, $href, $media);
25
        };
26
    }
27
28
    abstract protected function filterStyleLoaderTag(string $tag, string $handle, string $href, string $media): string;
29
}
30