TargetsAdminNoticesHook::getAdminNoticesCallback()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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