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.

Generic::withType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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