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
    {
@@ 304-313 (lines=10) @@
301
        }
302
    }
303
304
    public static function isInstanceOf($value, $class, $message = '')
305
    {
306
        if (!($value instanceof $class)) {
307
            static::reportInvalidArgument(sprintf(
308
                $message ?: 'Expected an instance of %2$s. Got: %s',
309
                static::typeToString($value),
310
                $class
311
            ));
312
        }
313
    }
314
315
    public static function notInstanceOf($value, $class, $message = '')
316
    {
@@ 315-324 (lines=10) @@
312
        }
313
    }
314
315
    public static function notInstanceOf($value, $class, $message = '')
316
    {
317
        if ($value instanceof $class) {
318
            static::reportInvalidArgument(sprintf(
319
                $message ?: 'Expected an instance other than %2$s. Got: %s',
320
                static::typeToString($value),
321
                $class
322
            ));
323
        }
324
    }
325
326
    public static function isEmpty($value, $message = '')
327
    {