TargetsCurrentScreenHook   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A targetCurrentScreenHook() 0 10 1
A getCurrentScreenPriority() 0 3 1
1
<?php
2
3
namespace Leonidas\Hooks;
4
5
use Closure;
6
use WP_Screen;
0 ignored issues
show
Bug introduced by
The type WP_Screen was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
trait TargetsCurrentScreenHook
9
{
10
    protected function targetCurrentScreenHook()
11
    {
12
        add_action(
13
            "current_screen",
14
            Closure::fromCallable([$this, 'doCurrentScreenAction']),
15
            $this->getCurrentScreenPriority(),
16
            PHP_INT_MAX
17
        );
18
19
        return $this;
20
    }
21
22
    protected function getCurrentScreenPriority(): int
23
    {
24
        return HOOK_DEFAULT_PRIORITY;
25
    }
26
27
    abstract protected function doCurrentScreenAction(WP_Screen $screen): void;
28
}
29