Test Failed
Push — master ( fdb79d...2e4512 )
by Chris
19:35
created

AbstractTaxonomyRegistrationModule   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
dl 0
loc 33
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A optionHandlers() 0 3 1
A hook() 0 3 1
A registerTaxonomies() 0 3 1
A doInitAction() 0 3 1
A taxonomyRegistrar() 0 3 1
1
<?php
2
3
namespace Leonidas\Framework\Modules;
4
5
use Leonidas\Contracts\Extension\ModuleInterface;
6
use Leonidas\Contracts\System\Taxonomy\TaxonomyInterface;
7
use Leonidas\Contracts\System\Taxonomy\TaxonomyOptionHandlerCollectionInterface;
8
use Leonidas\Contracts\System\Taxonomy\TaxonomyRegistrarInterface;
9
use Leonidas\Library\System\Taxonomy\TaxonomyRegistrar;
10
use Leonidas\Traits\Hooks\TargetsInitHook;
11
12
abstract class AbstractTaxonomyRegistrationModule extends AbstractModule 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