GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — develop ( 404db9...8cc0dc )
by Baptiste
03:06 queued 15s
created

Generic   A

Complexity

Total Complexity 41

Size/Duplication

Total Lines 265
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 83
dl 0
loc 265
ccs 111
cts 111
cp 1
rs 9.1199
c 0
b 0
f 0
wmc 41

41 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 3 1
A withContentType() 0 6 1
A hasId() 0 3 1
A correlationId() 0 3 1
A body() 0 3 1
A id() 0 3 1
A headers() 0 3 1
A withUserId() 0 6 1
A hasContentType() 0 3 1
A withTimestamp() 0 6 1
A withExpiration() 0 6 1
A hasContentEncoding() 0 3 1
A withAppId() 0 6 1
A withId() 0 6 1
A hasAppId() 0 3 1
A __construct() 0 4 1
A hasCorrelationId() 0 3 1
A hasExpiration() 0 3 1
A withPriority() 0 6 1
A hasReplyTo() 0 3 1
A replyTo() 0 3 1
A withDeliveryMode() 0 6 1
A hasUserId() 0 3 1
A hasType() 0 3 1
A priority() 0 3 1
A contentEncoding() 0 3 1
A withReplyTo() 0 6 1
A contentType() 0 3 1
A expiration() 0 3 1
A withContentEncoding() 0 6 1
A hasDeliveryMode() 0 3 1
A timestamp() 0 3 1
A userId() 0 3 1
A hasHeaders() 0 3 1
A withType() 0 6 1
A deliveryMode() 0 3 1
A hasPriority() 0 3 1
A withHeaders() 0 8 1
A withCorrelationId() 0 6 1
A appId() 0 3 1
A hasTimestamp() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like Generic often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Generic, and based on these observations, apply Extract Interface, too.

1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Model\Basic\Message;
5
6
use Innmind\AMQP\Model\Basic\Message;
7
use Innmind\TimeContinuum\{
8
    PointInTimeInterface,
9
    ElapsedPeriod,
10
};
11
use Innmind\Immutable\{
12
    MapInterface,
13
    Map,
14
    Str,
15
};
16
use function Innmind\Immutable\assertMap;
17
18
final class Generic implements Message
19
{
20
    private $contentType;
21
    private $contentEncoding;
22
    private $headers;
23
    private $deliveryMode;
24
    private $priority;
25
    private $correlationId;
26
    private $replyTo;
27
    private $expiration;
28
    private $id;
29
    private $timestamp;
30
    private $type;
31
    private $userId;
32
    private $appId;
33
    private $body;
34
35 68
    public function __construct(Str $body)
36
    {
37 68
        $this->body = $body->toEncoding('ASCII');
38 68
        $this->headers = new Map('string', 'mixed');
39 68
    }
40
41 30
    public function hasContentType(): bool
42
    {
43 30
        return $this->contentType instanceof ContentType;
44
    }
45
46 6
    public function contentType(): ContentType
47
    {
48 6
        return $this->contentType;
49
    }
50
51 6
    public function withContentType(ContentType $contentType): Message
52
    {
53 6
        $self = clone $this;
54 6
        $self->contentType = $contentType;
55
56 6
        return $self;
57
    }
58
59 30
    public function hasContentEncoding(): bool
60
    {
61 30
        return $this->contentEncoding instanceof ContentEncoding;
62
    }
63
64 6
    public function contentEncoding(): ContentEncoding
65
    {
66 6
        return $this->contentEncoding;
67
    }
68
69 6
    public function withContentEncoding(ContentEncoding $contentEncoding): Message
70
    {
71 6
        $self = clone $this;
72 6
        $self->contentEncoding = $contentEncoding;
73
74 6
        return $self;
75
    }
76
77 30
    public function hasHeaders(): bool
78
    {
79 30
        return $this->headers->size() > 0;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85 7
    public function headers(): MapInterface
86
    {
87 7
        return $this->headers;
88
    }
89
90 7
    public function withHeaders(MapInterface $headers): Message
91
    {
92 7
        assertMap('string', 'mixed', $headers, 1);
93
94 6
        $self = clone $this;
95 6
        $self->headers = $headers;
96
97 6
        return $self;
98
    }
99
100 30
    public function hasDeliveryMode(): bool
101
    {
102 30
        return $this->deliveryMode instanceof DeliveryMode;
103
    }
104
105 6
    public function deliveryMode(): DeliveryMode
106
    {
107 6
        return $this->deliveryMode;
108
    }
109
110 6
    public function withDeliveryMode(DeliveryMode $deliveryMode): Message
111
    {
112 6
        $self = clone $this;
113 6
        $self->deliveryMode = $deliveryMode;
114
115 6
        return $self;
116
    }
117
118 30
    public function hasPriority(): bool
119
    {
120 30
        return $this->priority instanceof Priority;
121
    }
122
123 6
    public function priority(): Priority
124
    {
125 6
        return $this->priority;
126
    }
127
128 6
    public function withPriority(Priority $priority): Message
129
    {
130 6
        $self = clone $this;
131 6
        $self->priority = $priority;
132
133 6
        return $self;
134
    }
135
136 30
    public function hasCorrelationId(): bool
137
    {
138 30
        return $this->correlationId instanceof CorrelationId;
139
    }
140
141 6
    public function correlationId(): CorrelationId
142
    {
143 6
        return $this->correlationId;
144
    }
145
146 6
    public function withCorrelationId(CorrelationId $correlationId): Message
147
    {
148 6
        $self = clone $this;
149 6
        $self->correlationId = $correlationId;
150
151 6
        return $self;
152
    }
153
154 30
    public function hasReplyTo(): bool
155
    {
156 30
        return $this->replyTo instanceof ReplyTo;
157
    }
158
159 6
    public function replyTo(): ReplyTo
160
    {
161 6
        return $this->replyTo;
162
    }
163
164 6
    public function withReplyTo(ReplyTo $replyTo): Message
165
    {
166 6
        $self = clone $this;
167 6
        $self->replyTo = $replyTo;
168
169 6
        return $self;
170
    }
171
172 30
    public function hasExpiration(): bool
173
    {
174 30
        return $this->expiration instanceof ElapsedPeriod;
175
    }
176
177 6
    public function expiration(): ElapsedPeriod
178
    {
179 6
        return $this->expiration;
180
    }
181
182 6
    public function withExpiration(ElapsedPeriod $expiration): Message
183
    {
184 6
        $self = clone $this;
185 6
        $self->expiration = $expiration;
186
187 6
        return $self;
188
    }
189
190 30
    public function hasId(): bool
191
    {
192 30
        return $this->id instanceof Id;
193
    }
194
195 6
    public function id(): Id
196
    {
197 6
        return $this->id;
198
    }
199
200 6
    public function withId(Id $id): Message
201
    {
202 6
        $self = clone $this;
203 6
        $self->id = $id;
204
205 6
        return $self;
206
    }
207
208 30
    public function hasTimestamp(): bool
209
    {
210 30
        return $this->timestamp instanceof PointInTimeInterface;
211
    }
212
213 6
    public function timestamp(): PointInTimeInterface
214
    {
215 6
        return $this->timestamp;
216
    }
217
218 6
    public function withTimestamp(PointInTimeInterface $timestamp): Message
219
    {
220 6
        $self = clone $this;
221 6
        $self->timestamp = $timestamp;
222
223 6
        return $self;
224
    }
225
226 30
    public function hasType(): bool
227
    {
228 30
        return $this->type instanceof Type;
229
    }
230
231 6
    public function type(): Type
232
    {
233 6
        return $this->type;
234
    }
235
236 6
    public function withType(Type $type): Message
237
    {
238 6
        $self = clone $this;
239 6
        $self->type = $type;
240
241 6
        return $self;
242
    }
243
244 30
    public function hasUserId(): bool
245
    {
246 30
        return $this->userId instanceof UserId;
247
    }
248
249 6
    public function userId(): UserId
250
    {
251 6
        return $this->userId;
252
    }
253
254 6
    public function withUserId(UserId $userId): Message
255
    {
256 6
        $self = clone $this;
257 6
        $self->userId = $userId;
258
259 6
        return $self;
260
    }
261
262 30
    public function hasAppId(): bool
263
    {
264 30
        return $this->appId instanceof AppId;
265
    }
266
267 6
    public function appId(): AppId
268
    {
269 6
        return $this->appId;
270
    }
271
272 6
    public function withAppId(AppId $appId): Message
273
    {
274 6
        $self = clone $this;
275 6
        $self->appId = $appId;
276
277 6
        return $self;
278
    }
279
280 28
    public function body(): Str
281
    {
282 28
        return $this->body;
283
    }
284
}
285