Failed Conditions
Pull Request — master (#126)
by
unknown
08:09
created

Extra   B

Complexity

Total Complexity 47

Size/Duplication

Total Lines 488
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 47
lcom 0
cbo 1
dl 0
loc 488
rs 8.64
c 0
b 0
f 0
ccs 0
cts 188
cp 0

47 Methods

Rating   Name   Duplication   Size   Complexity  
A nullOrString() 0 4 1
A allString() 0 4 1
A nullOrStringNotEmpty() 0 4 1
A allStringNotEmpty() 0 4 1
A nullOrInteger() 0 4 1
A allInteger() 0 4 1
A nullOrIntegerish() 0 4 1
A allIntegerish() 0 4 1
A nullOrFloat() 0 4 1
A allFloat() 0 4 1
A nullOrNumeric() 0 4 1
A allNumeric() 0 4 1
A nullOrNatural() 0 4 1
A allNatural() 0 4 1
A nullOrBoolean() 0 4 1
A allBoolean() 0 4 1
A nullOrScalar() 0 4 1
A allScalar() 0 4 1
A nullOrObject() 0 4 1
A allObject() 0 4 1
A nullOrResource() 0 4 1
A allResource() 0 4 1
A nullOrIsCallable() 0 4 1
A allIsCallable() 0 4 1
A nullOrIsArray() 0 4 1
A allIsArray() 0 4 1
A nullOrIsTraversable() 0 4 1
A allIsTraversable() 0 4 1
A nullOrIsCountable() 0 4 1
A allIsCountable() 0 4 1
A nullOrIsIterable() 0 4 1
A allIsIterable() 0 4 1
A nullOrIsInstanceOf() 0 4 1
A allIsInstanceOf() 0 4 1
A nullOrIsEmpty() 0 4 1
A allIsEmpty() 0 4 1
A allNull() 0 4 1
A nullOrTrue() 0 4 1
A allTrue() 0 4 1
A nullOrFalse() 0 4 1
A allFalse() 0 4 1
A nullOrOneOf() 0 4 1
A allOneOf() 0 4 1
A nullOrClassExists() 0 4 1
A allClassExists() 0 4 1
A nullOrInterfaceExists() 0 4 1
A allInterfaceExists() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Extra 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

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 Extra, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * Automatically generated
5
 */
6
7
namespace Webmozart\Assert;
8
9
class Extra extends Assert
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
10
{
11
    /**
12
     * @psalm-assert null|string $value
13
     * @param mixed $value
14
     * @param string $message
15
     */
16
    public static function nullOrString($value, $message = '')
17
    {
18
        parent::nullOrString($value, $message);
19
    }
20
21
    /**
22
     * @psalm-assert array<array-key,string> $value
23
     * @param mixed $value
24
     * @param string $message
25
     */
26
    public static function allString($value, $message = '')
27
    {
28
        parent::allString($value, $message);
29
    }
30
31
    /**
32
     * @psalm-assert null|string $value
33
     * @param mixed $value
34
     * @param string $message
35
     */
36
    public static function nullOrStringNotEmpty($value, $message = '')
37
    {
38
        parent::nullOrStringNotEmpty($value, $message);
39
    }
40
41
    /**
42
     * @psalm-assert array<array-key,string> $value
43
     * @param mixed $value
44
     * @param string $message
45
     */
46
    public static function allStringNotEmpty($value, $message = '')
47
    {
48
        parent::allStringNotEmpty($value, $message);
49
    }
50
51
    /**
52
     * @psalm-assert null|int $value
53
     * @param mixed $value
54
     * @param string $message
55
     */
56
    public static function nullOrInteger($value, $message = '')
57
    {
58
        parent::nullOrInteger($value, $message);
59
    }
60
61
    /**
62
     * @psalm-assert array<array-key,int> $value
63
     * @param mixed $value
64
     * @param string $message
65
     */
66
    public static function allInteger($value, $message = '')
67
    {
68
        parent::allInteger($value, $message);
69
    }
70
71
    /**
72
     * @psalm-assert null|numeric $value
73
     * @param mixed $value
74
     * @param string $message
75
     */
76
    public static function nullOrIntegerish($value, $message = '')
77
    {
78
        parent::nullOrIntegerish($value, $message);
79
    }
80
81
    /**
82
     * @psalm-assert array<array-key,numeric> $value
83
     * @param mixed $value
84
     * @param string $message
85
     */
86
    public static function allIntegerish($value, $message = '')
87
    {
88
        parent::allIntegerish($value, $message);
89
    }
90
91
    /**
92
     * @psalm-assert null|float $value
93
     * @param mixed $value
94
     * @param string $message
95
     */
96
    public static function nullOrFloat($value, $message = '')
97
    {
98
        parent::nullOrFloat($value, $message);
99
    }
100
101
    /**
102
     * @psalm-assert array<array-key,float> $value
103
     * @param mixed $value
104
     * @param string $message
105
     */
106
    public static function allFloat($value, $message = '')
107
    {
108
        parent::allFloat($value, $message);
109
    }
110
111
    /**
112
     * @psalm-assert null|numeric $value
113
     * @param mixed $value
114
     * @param string $message
115
     */
116
    public static function nullOrNumeric($value, $message = '')
117
    {
118
        parent::nullOrNumeric($value, $message);
119
    }
120
121
    /**
122
     * @psalm-assert array<array-key,numeric> $value
123
     * @param mixed $value
124
     * @param string $message
125
     */
126
    public static function allNumeric($value, $message = '')
127
    {
128
        parent::allNumeric($value, $message);
129
    }
130
131
    /**
132
     * @psalm-assert null|int $value
133
     * @param mixed $value
134
     * @param string $message
135
     */
136
    public static function nullOrNatural($value, $message = '')
137
    {
138
        parent::nullOrNatural($value, $message);
139
    }
140
141
    /**
142
     * @psalm-assert array<array-key,int> $value
143
     * @param mixed $value
144
     * @param string $message
145
     */
146
    public static function allNatural($value, $message = '')
147
    {
148
        parent::allNatural($value, $message);
149
    }
150
151
    /**
152
     * @psalm-assert null|bool $value
153
     * @param mixed $value
154
     * @param string $message
155
     */
156
    public static function nullOrBoolean($value, $message = '')
157
    {
158
        parent::nullOrBoolean($value, $message);
159
    }
160
161
    /**
162
     * @psalm-assert array<array-key,bool> $value
163
     * @param mixed $value
164
     * @param string $message
165
     */
166
    public static function allBoolean($value, $message = '')
167
    {
168
        parent::allBoolean($value, $message);
169
    }
170
171
    /**
172
     * @psalm-assert null|scalar $value
173
     * @param mixed $value
174
     * @param string $message
175
     */
176
    public static function nullOrScalar($value, $message = '')
177
    {
178
        parent::nullOrScalar($value, $message);
179
    }
180
181
    /**
182
     * @psalm-assert array<array-key,scalar> $value
183
     * @param mixed $value
184
     * @param string $message
185
     */
186
    public static function allScalar($value, $message = '')
187
    {
188
        parent::allScalar($value, $message);
189
    }
190
191
    /**
192
     * @psalm-assert null|object $value
193
     * @param mixed $value
194
     * @param string $message
195
     */
196
    public static function nullOrObject($value, $message = '')
197
    {
198
        parent::nullOrObject($value, $message);
199
    }
200
201
    /**
202
     * @psalm-assert array<array-key,object> $value
203
     * @param mixed $value
204
     * @param string $message
205
     */
206
    public static function allObject($value, $message = '')
207
    {
208
        parent::allObject($value, $message);
209
    }
210
211
    /**
212
     * @psalm-assert null|resource $value
213
     * @param mixed $value
214
     * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php
215
     * @param string $message
216
     */
217
    public static function nullOrResource($value, $type = null, $message = '')
218
    {
219
        parent::nullOrResource($value, $type, $message);
220
    }
221
222
    /**
223
     * @psalm-assert array<array-key,resource> $value
224
     * @param mixed $value
225
     * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php
226
     * @param string $message
227
     */
228
    public static function allResource($value, $type = null, $message = '')
229
    {
230
        parent::allResource($value, $type, $message);
231
    }
232
233
    /**
234
     * @psalm-assert null|callable $value
235
     * @param mixed $value
236
     * @param string $message
237
     */
238
    public static function nullOrIsCallable($value, $message = '')
239
    {
240
        parent::nullOrIsCallable($value, $message);
241
    }
242
243
    /**
244
     * @psalm-assert array<array-key,callable> $value
245
     * @param mixed $value
246
     * @param string $message
247
     */
248
    public static function allIsCallable($value, $message = '')
249
    {
250
        parent::allIsCallable($value, $message);
251
    }
252
253
    /**
254
     * @psalm-assert null|array $value
255
     * @param mixed $value
256
     * @param string $message
257
     */
258
    public static function nullOrIsArray($value, $message = '')
259
    {
260
        parent::nullOrIsArray($value, $message);
261
    }
262
263
    /**
264
     * @psalm-assert array<array-key,array> $value
265
     * @param mixed $value
266
     * @param string $message
267
     */
268
    public static function allIsArray($value, $message = '')
269
    {
270
        parent::allIsArray($value, $message);
271
    }
272
273
    /**
274
     * @psalm-assert null|iterable $value
275
     * @deprecated use "isIterable" or "isInstanceOf" instead
276
     * @param mixed $value
277
     * @param string $message
278
     */
279
    public static function nullOrIsTraversable($value, $message = '')
280
    {
281
        parent::nullOrIsTraversable($value, $message);
282
    }
283
284
    /**
285
     * @psalm-assert array<array-key,iterable> $value
286
     * @deprecated use "isIterable" or "isInstanceOf" instead
287
     * @param mixed $value
288
     * @param string $message
289
     */
290
    public static function allIsTraversable($value, $message = '')
291
    {
292
        parent::allIsTraversable($value, $message);
293
    }
294
295
    /**
296
     * @psalm-assert null|countable $value
297
     * @param mixed $value
298
     * @param string $message
299
     */
300
    public static function nullOrIsCountable($value, $message = '')
301
    {
302
        parent::nullOrIsCountable($value, $message);
303
    }
304
305
    /**
306
     * @psalm-assert array<array-key,countable> $value
307
     * @param mixed $value
308
     * @param string $message
309
     */
310
    public static function allIsCountable($value, $message = '')
311
    {
312
        parent::allIsCountable($value, $message);
313
    }
314
315
    /**
316
     * @psalm-assert null|iterable $value
317
     * @param mixed $value
318
     * @param string $message
319
     */
320
    public static function nullOrIsIterable($value, $message = '')
321
    {
322
        parent::nullOrIsIterable($value, $message);
323
    }
324
325
    /**
326
     * @psalm-assert array<array-key,iterable> $value
327
     * @param mixed $value
328
     * @param string $message
329
     */
330
    public static function allIsIterable($value, $message = '')
331
    {
332
        parent::allIsIterable($value, $message);
333
    }
334
335
    /**
336
     * @psalm-template ExpectedType of object
337
     * @psalm-param class-string<ExpectedType> $class
338
     * @psalm-assert null|ExpectedType $value
339
     * @param mixed $value
340
     * @param string|object $class
341
     * @param string $message
342
     */
343
    public static function nullOrIsInstanceOf($value, $class, $message = '')
344
    {
345
        parent::nullOrIsInstanceOf($value, $class, $message);
346
    }
347
348
    /**
349
     * @psalm-template ExpectedType of object
350
     * @psalm-param class-string<ExpectedType> $class
351
     * @psalm-assert array<array-key,ExpectedType> $value
352
     * @param mixed $value
353
     * @param string|object $class
354
     * @param string $message
355
     */
356
    public static function allIsInstanceOf($value, $class, $message = '')
357
    {
358
        parent::allIsInstanceOf($value, $class, $message);
359
    }
360
361
    /**
362
     * @psalm-assert null|empty $value
363
     * @param mixed $value
364
     * @param string $message
365
     */
366
    public static function nullOrIsEmpty($value, $message = '')
367
    {
368
        parent::nullOrIsEmpty($value, $message);
369
    }
370
371
    /**
372
     * @psalm-assert array<array-key,empty> $value
373
     * @param mixed $value
374
     * @param string $message
375
     */
376
    public static function allIsEmpty($value, $message = '')
377
    {
378
        parent::allIsEmpty($value, $message);
379
    }
380
381
    /**
382
     * @psalm-assert array<array-key,null> $value
383
     * @param mixed $value
384
     * @param string $message
385
     */
386
    public static function allNull($value, $message = '')
387
    {
388
        parent::allNull($value, $message);
389
    }
390
391
    /**
392
     * @psalm-assert null|true $value
393
     * @param mixed $value
394
     * @param string $message
395
     */
396
    public static function nullOrTrue($value, $message = '')
397
    {
398
        parent::nullOrTrue($value, $message);
399
    }
400
401
    /**
402
     * @psalm-assert array<array-key,true> $value
403
     * @param mixed $value
404
     * @param string $message
405
     */
406
    public static function allTrue($value, $message = '')
407
    {
408
        parent::allTrue($value, $message);
409
    }
410
411
    /**
412
     * @psalm-assert null|false $value
413
     * @param mixed $value
414
     * @param string $message
415
     */
416
    public static function nullOrFalse($value, $message = '')
417
    {
418
        parent::nullOrFalse($value, $message);
419
    }
420
421
    /**
422
     * @psalm-assert array<array-key,false> $value
423
     * @param mixed $value
424
     * @param string $message
425
     */
426
    public static function allFalse($value, $message = '')
427
    {
428
        parent::allFalse($value, $message);
429
    }
430
431
    /**
432
     * @psalm-template ExpectedType
433
     * @psalm-param array<ExpectedType> $values
434
     * @psalm-assert null|ExpectedType $value
435
     * @param mixed $value
436
     * @param array $values
437
     * @param string $message
438
     */
439
    public static function nullOrOneOf($value, $values, $message = '')
440
    {
441
        parent::nullOrOneOf($value, $values, $message);
442
    }
443
444
    /**
445
     * @psalm-template ExpectedType
446
     * @psalm-param array<ExpectedType> $values
447
     * @psalm-assert array<array-key,ExpectedType> $value
448
     * @param mixed $value
449
     * @param array $values
450
     * @param string $message
451
     */
452
    public static function allOneOf($value, $values, $message = '')
453
    {
454
        parent::allOneOf($value, $values, $message);
0 ignored issues
show
Unused Code introduced by
The call to Assert::allOneOf() has too many arguments starting with $message.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
455
    }
456
457
    /**
458
     * @psalm-assert null|class-string $value
459
     * @param mixed $value
460
     * @param string $message
461
     */
462
    public static function nullOrClassExists($value, $message = '')
463
    {
464
        parent::nullOrClassExists($value, $message);
465
    }
466
467
    /**
468
     * @psalm-assert array<array-key,class-string> $value
469
     * @param mixed $value
470
     * @param string $message
471
     */
472
    public static function allClassExists($value, $message = '')
473
    {
474
        parent::allClassExists($value, $message);
475
    }
476
477
    /**
478
     * @psalm-assert null|class-string $value
479
     * @param mixed $value
480
     * @param string $message
481
     */
482
    public static function nullOrInterfaceExists($value, $message = '')
483
    {
484
        parent::nullOrInterfaceExists($value, $message);
485
    }
486
487
    /**
488
     * @psalm-assert array<array-key,class-string> $value
489
     * @param mixed $value
490
     * @param string $message
491
     */
492
    public static function allInterfaceExists($value, $message = '')
493
    {
494
        parent::allInterfaceExists($value, $message);
495
    }
496
}
497