Description::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 27
nc 1
nop 13

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
declare(strict_types=1);
3
4
namespace Ytake\KsqlClient\Entity;
5
6
/**
7
 * Class Description
8
 */
9
final class Description extends AbstractKsql
10
{
11
    /** @var string */
12
    private $name;
13
14
    /** @var RunningQuery[] */
15
    private $readQueries;
16
17
    /** @var RunningQuery[] */
18
    private $writeQueries;
19
20
    /** @var FieldSchema */
21
    private $schema;
22
23
    /** @var string */
24
    private $type;
25
26
    /** @var string */
27
    private $key;
28
29
    /** @var string */
30
    private $timestamp;
31
32
    /** @var string */
33
    private $statistics;
34
35
    /** @var string */
36
    private $errorStats;
37
38
    /** @var bool */
39
    private $extended;
40
41
    /** @var int */
42
    private $partitions;
43
44
    /** @var int */
45
    private $replication;
46
47
    /**
48
     * @param string $statementText
49
     * @param string $name
50
     * @param array  $readQueries
51
     * @param array  $writeQueries
52
     * @param array  $schema
53
     * @param string $type
54
     * @param string $key
55
     * @param string $timestamp
56
     * @param string $statistics
57
     * @param string $errorStats
58
     * @param bool   $extended
59
     * @param int    $partitions
60
     * @param int    $replication
61
     */
62
    public function __construct(
63
        string $statementText,
64
        string $name,
65
        array $readQueries,
66
        array $writeQueries,
67
        array $schema,
68
        string $type,
69
        string $key,
70
        string $timestamp,
71
        string $statistics,
72
        string $errorStats,
73
        bool $extended,
74
        int $partitions,
75
        int $replication
76
    ) {
77
        parent::__construct($statementText);
78
        $this->name = $name;
79
        $this->readQueries = $readQueries;
80
        $this->writeQueries = $writeQueries;
81
        $this->schema = $schema;
0 ignored issues
show
Documentation Bug introduced by
It seems like $schema of type array is incompatible with the declared type object<Ytake\KsqlClient\Entity\FieldSchema> of property $schema.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
82
        $this->type = $type;
83
        $this->key = $key;
84
        $this->timestamp = $timestamp;
85
        $this->statistics = $statistics;
86
        $this->errorStats = $errorStats;
87
        $this->extended = $extended;
88
        $this->partitions = $partitions;
89
        $this->replication = $replication;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getName(): string
96
    {
97
        return $this->name;
98
    }
99
100
    /**
101
     * @return RunningQuery[]
102
     */
103
    public function getReadQueries(): array
104
    {
105
        return $this->readQueries;
106
    }
107
108
    /**
109
     * @return RunningQuery[]
110
     */
111
    public function getWriteQueries(): array
112
    {
113
        return $this->writeQueries;
114
    }
115
116
    /**
117
     * @return FieldSchema
118
     */
119
    public function getSchema(): FieldSchema
120
    {
121
        return $this->schema;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getType(): string
128
    {
129
        return $this->type;
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getKey(): string
136
    {
137
        return $this->key;
138
    }
139
140
    /**
141
     * @return string
142
     */
143
    public function getTimestamp(): string
144
    {
145
        return $this->timestamp;
146
    }
147
148
    /**
149
     * @return string
150
     */
151
    public function getStatistics(): string
152
    {
153
        return $this->statistics;
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function getErrorStats(): string
160
    {
161
        return $this->errorStats;
162
    }
163
164
    /**
165
     * @return bool
166
     */
167
    public function isExtended(): bool
168
    {
169
        return $this->extended;
170
    }
171
172
    /**
173
     * @return int
174
     */
175
    public function getPartitions(): int
176
    {
177
        return $this->partitions;
178
    }
179
180
    /**
181
     * @return int
182
     */
183
    public function getReplication(): int
184
    {
185
        return $this->replication;
186
    }
187
}
188