Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

@@ 176-184 (lines=9) @@
173
        static::notEmpty($value, $message);
174
    }
175
176
    public static function integer($value, $message = '')
177
    {
178
        if (!is_int($value)) {
179
            static::reportInvalidArgument(sprintf(
180
                $message ?: 'Expected an integer. Got: %s',
181
                static::typeToString($value)
182
            ));
183
        }
184
    }
185
186
    public static function integerish($value, $message = '')
187
    {
@@ 186-194 (lines=9) @@
183
        }
184
    }
185
186
    public static function integerish($value, $message = '')
187
    {
188
        if (!is_numeric($value) || $value != (int) $value) {
189
            static::reportInvalidArgument(sprintf(
190
                $message ?: 'Expected an integerish value. Got: %s',
191
                static::typeToString($value)
192
            ));
193
        }
194
    }
195
196
    public static function float($value, $message = '')
197
    {
@@ 196-204 (lines=9) @@
193
        }
194
    }
195
196
    public static function float($value, $message = '')
197
    {
198
        if (!is_float($value)) {
199
            static::reportInvalidArgument(sprintf(
200
                $message ?: 'Expected a float. Got: %s',
201
                static::typeToString($value)
202
            ));
203
        }
204
    }
205
206
    public static function numeric($value, $message = '')
207
    {
@@ 206-214 (lines=9) @@
203
        }
204
    }
205
206
    public static function numeric($value, $message = '')
207
    {
208
        if (!is_numeric($value)) {
209
            static::reportInvalidArgument(sprintf(
210
                $message ?: 'Expected a numeric. Got: %s',
211
                static::typeToString($value)
212
            ));
213
        }
214
    }
215
216
    public static function boolean($value, $message = '')
217
    {
@@ 216-224 (lines=9) @@
213
        }
214
    }
215
216
    public static function boolean($value, $message = '')
217
    {
218
        if (!is_bool($value)) {
219
            static::reportInvalidArgument(sprintf(
220
                $message ?: 'Expected a boolean. Got: %s',
221
                static::typeToString($value)
222
            ));
223
        }
224
    }
225
226
    public static function scalar($value, $message = '')
227
    {
@@ 226-234 (lines=9) @@
223
        }
224
    }
225
226
    public static function scalar($value, $message = '')
227
    {
228
        if (!is_scalar($value)) {
229
            static::reportInvalidArgument(sprintf(
230
                $message ?: 'Expected a scalar. Got: %s',
231
                static::typeToString($value)
232
            ));
233
        }
234
    }
235
236
    public static function object($value, $message = '')
237
    {
@@ 236-244 (lines=9) @@
233
        }
234
    }
235
236
    public static function object($value, $message = '')
237
    {
238
        if (!is_object($value)) {
239
            static::reportInvalidArgument(sprintf(
240
                $message ?: 'Expected an object. Got: %s',
241
                static::typeToString($value)
242
            ));
243
        }
244
    }
245
246
    public static function resource($value, $type = null, $message = '')
247
    {
@@ 264-272 (lines=9) @@
261
        }
262
    }
263
264
    public static function isCallable($value, $message = '')
265
    {
266
        if (!is_callable($value)) {
267
            static::reportInvalidArgument(sprintf(
268
                $message ?: 'Expected a callable. Got: %s',
269
                static::typeToString($value)
270
            ));
271
        }
272
    }
273
274
    public static function isArray($value, $message = '')
275
    {
@@ 274-282 (lines=9) @@
271
        }
272
    }
273
274
    public static function isArray($value, $message = '')
275
    {
276
        if (!is_array($value)) {
277
            static::reportInvalidArgument(sprintf(
278
                $message ?: 'Expected an array. Got: %s',
279
                static::typeToString($value)
280
            ));
281
        }
282
    }
283
284
    public static function isTraversable($value, $message = '')
285
    {
@@ 322-331 (lines=10) @@
319
        }
320
    }
321
322
    public static function isInstanceOf($value, $class, $message = '')
323
    {
324
        if (!($value instanceof $class)) {
325
            static::reportInvalidArgument(sprintf(
326
                $message ?: 'Expected an instance of %2$s. Got: %s',
327
                static::typeToString($value),
328
                $class
329
            ));
330
        }
331
    }
332
333
    public static function notInstanceOf($value, $class, $message = '')
334
    {
@@ 333-342 (lines=10) @@
330
        }
331
    }
332
333
    public static function notInstanceOf($value, $class, $message = '')
334
    {
335
        if ($value instanceof $class) {
336
            static::reportInvalidArgument(sprintf(
337
                $message ?: 'Expected an instance other than %2$s. Got: %s',
338
                static::typeToString($value),
339
                $class
340
            ));
341
        }
342
    }
343
344
    public static function isEmpty($value, $message = '')
345
    {