Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

@@ 185-193 (lines=9) @@
182
        static::notEq($value, '', $message);
183
    }
184
185
    public static function integer($value, $message = '')
186
    {
187
        if (!is_int($value)) {
188
            static::reportInvalidArgument(sprintf(
189
                $message ?: 'Expected an integer. Got: %s',
190
                static::typeToString($value)
191
            ));
192
        }
193
    }
194
195
    public static function integerish($value, $message = '')
196
    {
@@ 195-203 (lines=9) @@
192
        }
193
    }
194
195
    public static function integerish($value, $message = '')
196
    {
197
        if (!is_numeric($value) || $value != (int) $value) {
198
            static::reportInvalidArgument(sprintf(
199
                $message ?: 'Expected an integerish value. Got: %s',
200
                static::typeToString($value)
201
            ));
202
        }
203
    }
204
205
    public static function float($value, $message = '')
206
    {
@@ 205-213 (lines=9) @@
202
        }
203
    }
204
205
    public static function float($value, $message = '')
206
    {
207
        if (!is_float($value)) {
208
            static::reportInvalidArgument(sprintf(
209
                $message ?: 'Expected a float. Got: %s',
210
                static::typeToString($value)
211
            ));
212
        }
213
    }
214
215
    public static function numeric($value, $message = '')
216
    {
@@ 215-223 (lines=9) @@
212
        }
213
    }
214
215
    public static function numeric($value, $message = '')
216
    {
217
        if (!is_numeric($value)) {
218
            static::reportInvalidArgument(sprintf(
219
                $message ?: 'Expected a numeric. Got: %s',
220
                static::typeToString($value)
221
            ));
222
        }
223
    }
224
225
    public static function natural($value, $message = '')
226
    {
@@ 235-243 (lines=9) @@
232
        }
233
    }
234
235
    public static function boolean($value, $message = '')
236
    {
237
        if (!is_bool($value)) {
238
            static::reportInvalidArgument(sprintf(
239
                $message ?: 'Expected a boolean. Got: %s',
240
                static::typeToString($value)
241
            ));
242
        }
243
    }
244
245
    public static function scalar($value, $message = '')
246
    {
@@ 245-253 (lines=9) @@
242
        }
243
    }
244
245
    public static function scalar($value, $message = '')
246
    {
247
        if (!is_scalar($value)) {
248
            static::reportInvalidArgument(sprintf(
249
                $message ?: 'Expected a scalar. Got: %s',
250
                static::typeToString($value)
251
            ));
252
        }
253
    }
254
255
    public static function object($value, $message = '')
256
    {
@@ 255-263 (lines=9) @@
252
        }
253
    }
254
255
    public static function object($value, $message = '')
256
    {
257
        if (!is_object($value)) {
258
            static::reportInvalidArgument(sprintf(
259
                $message ?: 'Expected an object. Got: %s',
260
                static::typeToString($value)
261
            ));
262
        }
263
    }
264
265
    public static function resource($value, $type = null, $message = '')
266
    {
@@ 283-291 (lines=9) @@
280
        }
281
    }
282
283
    public static function isCallable($value, $message = '')
284
    {
285
        if (!is_callable($value)) {
286
            static::reportInvalidArgument(sprintf(
287
                $message ?: 'Expected a callable. Got: %s',
288
                static::typeToString($value)
289
            ));
290
        }
291
    }
292
293
    public static function isArray($value, $message = '')
294
    {
@@ 293-301 (lines=9) @@
290
        }
291
    }
292
293
    public static function isArray($value, $message = '')
294
    {
295
        if (!is_array($value)) {
296
            static::reportInvalidArgument(sprintf(
297
                $message ?: 'Expected an array. Got: %s',
298
                static::typeToString($value)
299
            ));
300
        }
301
    }
302
303
    public static function isTraversable($value, $message = '')
304
    {
@@ 351-360 (lines=10) @@
348
        }
349
    }
350
351
    public static function isInstanceOf($value, $class, $message = '')
352
    {
353
        if (!($value instanceof $class)) {
354
            static::reportInvalidArgument(sprintf(
355
                $message ?: 'Expected an instance of %2$s. Got: %s',
356
                static::typeToString($value),
357
                $class
358
            ));
359
        }
360
    }
361
362
    public static function notInstanceOf($value, $class, $message = '')
363
    {
@@ 362-371 (lines=10) @@
359
        }
360
    }
361
362
    public static function notInstanceOf($value, $class, $message = '')
363
    {
364
        if ($value instanceof $class) {
365
            static::reportInvalidArgument(sprintf(
366
                $message ?: 'Expected an instance other than %2$s. Got: %s',
367
                static::typeToString($value),
368
                $class
369
            ));
370
        }
371
    }
372
373
    public static function isInstanceOfAny($value, array $classes, $message = '')
374
    {