TaxonomyRegistrationModule::doInitAction()   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\Taxonomy\TaxonomyInterface;
7
use Leonidas\Contracts\System\Model\Taxonomy\TaxonomyOptionHandlerCollectionInterface;
8
use Leonidas\Contracts\System\Model\Taxonomy\TaxonomyRegistrarInterface;
9
use Leonidas\Hooks\TargetsInitHook;
10
use Leonidas\Library\System\Model\Taxonomy\TaxonomyRegistrar;
11
12
abstract class TaxonomyRegistrationModule 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->registerTaxonomies();
24
    }
25
26
    protected function registerTaxonomies(): void
27
    {
28
        $this->taxonomyRegistrar()->registerMany(...$this->taxonomies());
29
    }
30
31
    protected function taxonomyRegistrar(): TaxonomyRegistrarInterface
32
    {
33
        return new TaxonomyRegistrar($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(): ?TaxonomyOptionHandlerCollectionInterface
37
    {
38
        return null;
39
    }
40
41
    /**
42
     * @return TaxonomyInterface[]
43
     */
44
    abstract protected function taxonomies(): array;
45
}
46