Passed
Pull Request — master (#47)
by
unknown
11:29
created

Suite::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 13
rs 10
cc 1
nc 1
nop 11

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
declare(strict_types=1);
4
5
namespace hanneskod\readmetester\Config;
6
7
class Suite
8
{
9
    /**
10
     * @param array<string> $includePaths
11
     * @param array<string> $excludePaths
12
     * @param array<string> $fileExtensions
13
     * @param array<string> $globalAttributes
14
     */
15
    public function __construct(
16
        private string $name,
17
        private bool $active = true,
18
        private string $inputLanguage = '',
19
        private string $runner = '',
20
        private array $includePaths = [],
21
        private array $excludePaths = [],
22
        private array $fileExtensions = [],
23
        private array $globalAttributes = [],
24
        private bool $stopOnFailure = false,
25
        private string $filter = '',
26
        private bool $readFromStdin = false,
27
    ) {}
28
29
    public function getSuiteName(): string
30
    {
31
        return $this->name;
32
    }
33
34
    public function isActive(): bool
35
    {
36
        return $this->active;
37
    }
38
39
    public function getInputLanguage(): string
40
    {
41
        return $this->inputLanguage;
42
    }
43
44
    public function getRunner(): string
45
    {
46
        return $this->runner;
47
    }
48
49
    /** @return array<string> */
50
    public function getIncludePaths(): array
51
    {
52
        return $this->includePaths;
53
    }
54
55
    /** @return array<string> */
56
    public function getExcludePaths(): array
57
    {
58
        return $this->excludePaths;
59
    }
60
61
    /** @return array<string> */
62
    public function getFileExtensions(): array
63
    {
64
        return $this->fileExtensions;
65
    }
66
67
    public function readFromStdin(): bool
68
    {
69
        return $this->readFromStdin;
70
    }
71
72
    public function getFilter(): string
73
    {
74
        return $this->filter;
75
    }
76
77
    /** @return array<string> */
78
    public function getGlobalAttributes(): array
79
    {
80
        return $this->globalAttributes;
81
    }
82
83
    public function stopOnFailure(): bool
84
    {
85
        return $this->stopOnFailure;
86
    }
87
}
88