Test Failed
Push — master ( 135f34...8b25c6 )
by Chris
33:49
created

InteriorPage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 24
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 9

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Leonidas\Library\Admin\Component\Page;
4
5
use Leonidas\Contracts\Admin\AdminTitleResolverInterface;
6
use Leonidas\Contracts\Admin\Component\AdminPageLayoutInterface;
7
use Leonidas\Contracts\Admin\Component\InteriorPageInterface;
8
use Leonidas\Contracts\Admin\Component\LoadErrorPageInterface;
9
use Leonidas\Contracts\Admin\ParentFileResolverInterface;
10
use Leonidas\Contracts\Admin\SubmenuFileResolverInterface;
11
use Leonidas\Library\Admin\Component\Page\Abstracts\AbstractAdminPage;
12
use Leonidas\Library\Admin\Component\Page\Traits\NestedPageTrait;
13
14
class InteriorPage extends AbstractAdminPage implements InteriorPageInterface
15
{
16
    use NestedPageTrait;
17
18
    public function __construct(
19
        string $parentSlug,
20
        string $pageTitle,
21
        string $menuSlug,
22
        AdminPageLayoutInterface $layout,
23
        LoadErrorPageInterface $loadErrorPage,
24
        ?string $capability = null,
25
        ?AdminTitleResolverInterface $adminTitleResolver = null,
26
        ?ParentFileResolverInterface $parentFileResolver = null,
27
        ?SubmenuFileResolverInterface $subMenuFileResolver = null
28
    ) {
29
        NestedPageTrait::__construct(
30
            $parentSlug,
31
            $parentFileResolver,
32
            $subMenuFileResolver
33
        );
34
35
        parent::__construct(
36
            $pageTitle,
37
            $menuSlug,
0 ignored issues
show
Bug introduced by
$menuSlug of type string is incompatible with the type Leonidas\Contracts\Admin...eResolverInterface|null expected by parameter $parentFileResolver of Leonidas\Library\Admin\C...ageTrait::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
            /** @scrutinizer ignore-type */ $menuSlug,
Loading history...
38
            $layout,
0 ignored issues
show
Bug introduced by
$layout of type Leonidas\Contracts\Admin...dminPageLayoutInterface is incompatible with the type Leonidas\Contracts\Admin...eResolverInterface|null expected by parameter $subMenuFileResolver of Leonidas\Library\Admin\C...ageTrait::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
            /** @scrutinizer ignore-type */ $layout,
Loading history...
39
            $loadErrorPage,
0 ignored issues
show
Unused Code introduced by
The call to Leonidas\Library\Admin\C...ageTrait::__construct() has too many arguments starting with $loadErrorPage. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        parent::/** @scrutinizer ignore-call */ 
40
                __construct(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
40
            $capability,
41
            $adminTitleResolver
42
        );
43
    }
44
}
45