PostTypeRegistrationModule::postTypeRegistrar()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Leonidas\Framework\Module\Abstracts;
4
5
use Leonidas\Contracts\Extension\ModuleInterface;
6
use Leonidas\Contracts\System\Model\PostType\PostTypeInterface;
7
use Leonidas\Contracts\System\Model\PostType\PostTypeOptionHandlerCollectionInterface;
8
use Leonidas\Contracts\System\Model\PostType\PostTypeRegistrarInterface;
9
use Leonidas\Hooks\TargetsInitHook;
10
use Leonidas\Library\System\Model\PostType\PostTypeRegistrar;
11
12
abstract class PostTypeRegistrationModule extends Module implements ModuleInterface
13
{
14
    use TargetsInitHook;
15
16
    public function hook(): void
17
    {
18
        $this->targetInitHook();
19
    }
20
21
    protected function doInitAction(): void
22
    {
23
        $this->registerPostTypes();
24
    }
25
26
    protected function registerPostTypes(): void
27
    {
28
        $this->postTypeRegistrar()->registerMany(...$this->postTypes());
29
    }
30
31
    protected function postTypeRegistrar(): PostTypeRegistrarInterface
32
    {
33
        return new PostTypeRegistrar($this->optionHandlers());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->optionHandlers() targeting Leonidas\Framework\Modul...odule::optionHandlers() 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...
34
    }
35
36
    protected function optionHandlers(): ?PostTypeOptionHandlerCollectionInterface
37
    {
38
        return null;
39
    }
40
41
    /**
42
     * @return PostTypeInterface[]
43
     */
44
    abstract protected function postTypes(): array;
45
}
46