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

AbstractMenuPage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 20
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 8

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\Abstracts;
4
5
use Leonidas\Contracts\Admin\AdminTitleResolverInterface;
6
use Leonidas\Contracts\Admin\Component\AdminPageLayoutInterface;
7
use Leonidas\Contracts\Admin\Component\LoadErrorPageInterface;
8
9
abstract class AbstractMenuPage extends AbstractAdminPage
10
{
11
    protected string $menuTitle = '';
12
13
    protected int $position;
14
15
    public function __construct(
16
        string $pageTitle,
17
        string $menuTitle,
18
        string $menuSlug,
19
        int $position,
20
        AdminPageLayoutInterface $layout,
21
        LoadErrorPageInterface $loadErrorPage,
22
        ?string $capability = null,
23
        ?AdminTitleResolverInterface $adminTitleResolver = null
24
    ) {
25
        $this->menuTitle = $menuTitle;
26
        $this->position = $position;
27
28
        parent::__construct(
29
            $pageTitle,
30
            $menuSlug,
31
            $layout,
32
            $loadErrorPage,
33
            $capability,
34
            $adminTitleResolver
35
        );
36
    }
37
38
    public function getMenuTitle(): string
39
    {
40
        return $this->menuTitle;
41
    }
42
43
    public function getPosition(): int
44
    {
45
        return $this->position;
46
    }
47
}
48