Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

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