Test Failed
Push — master ( 8a7ae2...79eb97 )
by Chris
06:09
created

TargetsCurrentScreenHook   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentScreenPriority() 0 3 1
A targetCurrentScreenHook() 0 10 1
1
<?php
2
3
namespace Leonidas\Traits\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