ClassConfig::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 0
c 2
b 1
f 0
nc 1
nop 8
dl 0
loc 37
ccs 1
cts 1
cp 1
crap 1
rs 10

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 Yiisoft\Proxy\Config;
6
7
/**
8
 * @internal
9
 *
10
 * A class / an interface metadata. {@see ClassConfigFactory} is used for creation.
11
 */
12
final class ClassConfig
13
{
14 13
    public function __construct(
15
        /**
16
         * Whether it's config for a class (`false` value) or an interface (`true` value).
17
         */
18
        public bool $isInterface,
19
        /**
20
         * @var string Namespace, for example: `Yiisoft\Proxy\Tests\Stub`.
21
         *
22
         * @link https://www.php.net/manual/en/language.namespaces.php
23
         */
24
        public string $namespace,
25
        /**
26
         * @var string[] A list of modifiers, for example: `['final']`.
27
         */
28
        public array $modifiers,
29
        /**
30
         * @var string Full name including namespace, for example: `Yiisoft\Proxy\Tests\Stub\GraphInterface`.
31
         */
32
        public string $name,
33
        /**
34
         * @var string Short name without namespace, for example: `GraphInterface`.
35
         */
36
        public string $shortName,
37
        /**
38
         * @var string Full parent class name including namespace. Empty string means class have no parent class.
39
         */
40
        public string $parent,
41
        /**
42
         * @var string[] A list of interfaces this class implements or interface extends from.
43
         */
44
        public array $interfaces,
45
        /**
46
         * @var MethodConfig[] A map where key is a {@see $name} and value is {@see MethodConfig} instance.
47
         * @psalm-var array<string, MethodConfig>
48
         */
49
        public array $methods,
50
    ) {
51 13
    }
52
}
53