TargetsAdminNoticesHook   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 getAdminNoticesCallback() 0 4 1
A targetAdminNoticesHook() 0 10 1
1
<?php
2
3
namespace Leonidas\Hooks;
4
5
use Closure;
6
7
trait TargetsAdminNoticesHook
8
{
9
    protected function targetAdminNoticesHook()
10
    {
11
        add_action(
12
            'admin_notices',
13
            $this->getAdminNoticesCallback(),
14
            10,
15
            PHP_INT_MAX
16
        );
17
18
        return $this;
19
    }
20
21
    protected function getAdminNoticesCallback(): Closure
22
    {
23
        return function () {
24
            return $this->doAdminNoticesAction();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->doAdminNoticesAction() targeting Leonidas\Hooks\TargetsAd...:doAdminNoticesAction() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
25
        };
26
    }
27
28
    abstract protected function doAdminNoticesAction(): void;
29
}
30