Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

@@ 170-178 (lines=9) @@
167
        static::notEmpty($value, $message);
168
    }
169
170
    public static function integer($value, $message = '')
171
    {
172
        if (!is_int($value)) {
173
            static::reportInvalidArgument(sprintf(
174
                $message ?: 'Expected an integer. Got: %s',
175
                static::typeToString($value)
176
            ));
177
        }
178
    }
179
180
    public static function integerish($value, $message = '')
181
    {
@@ 180-188 (lines=9) @@
177
        }
178
    }
179
180
    public static function integerish($value, $message = '')
181
    {
182
        if (!is_numeric($value) || $value != (int) $value) {
183
            static::reportInvalidArgument(sprintf(
184
                $message ?: 'Expected an integerish value. Got: %s',
185
                static::typeToString($value)
186
            ));
187
        }
188
    }
189
190
    public static function float($value, $message = '')
191
    {
@@ 190-198 (lines=9) @@
187
        }
188
    }
189
190
    public static function float($value, $message = '')
191
    {
192
        if (!is_float($value)) {
193
            static::reportInvalidArgument(sprintf(
194
                $message ?: 'Expected a float. Got: %s',
195
                static::typeToString($value)
196
            ));
197
        }
198
    }
199
200
    public static function numeric($value, $message = '')
201
    {
@@ 200-208 (lines=9) @@
197
        }
198
    }
199
200
    public static function numeric($value, $message = '')
201
    {
202
        if (!is_numeric($value)) {
203
            static::reportInvalidArgument(sprintf(
204
                $message ?: 'Expected a numeric. Got: %s',
205
                static::typeToString($value)
206
            ));
207
        }
208
    }
209
210
    public static function boolean($value, $message = '')
211
    {
@@ 210-218 (lines=9) @@
207
        }
208
    }
209
210
    public static function boolean($value, $message = '')
211
    {
212
        if (!is_bool($value)) {
213
            static::reportInvalidArgument(sprintf(
214
                $message ?: 'Expected a boolean. Got: %s',
215
                static::typeToString($value)
216
            ));
217
        }
218
    }
219
220
    public static function scalar($value, $message = '')
221
    {
@@ 220-228 (lines=9) @@
217
        }
218
    }
219
220
    public static function scalar($value, $message = '')
221
    {
222
        if (!is_scalar($value)) {
223
            static::reportInvalidArgument(sprintf(
224
                $message ?: 'Expected a scalar. Got: %s',
225
                static::typeToString($value)
226
            ));
227
        }
228
    }
229
230
    public static function object($value, $message = '')
231
    {
@@ 230-238 (lines=9) @@
227
        }
228
    }
229
230
    public static function object($value, $message = '')
231
    {
232
        if (!is_object($value)) {
233
            static::reportInvalidArgument(sprintf(
234
                $message ?: 'Expected an object. Got: %s',
235
                static::typeToString($value)
236
            ));
237
        }
238
    }
239
240
    public static function resource($value, $type = null, $message = '')
241
    {
@@ 258-266 (lines=9) @@
255
        }
256
    }
257
258
    public static function isCallable($value, $message = '')
259
    {
260
        if (!is_callable($value)) {
261
            static::reportInvalidArgument(sprintf(
262
                $message ?: 'Expected a callable. Got: %s',
263
                static::typeToString($value)
264
            ));
265
        }
266
    }
267
268
    public static function isArray($value, $message = '')
269
    {
@@ 268-276 (lines=9) @@
265
        }
266
    }
267
268
    public static function isArray($value, $message = '')
269
    {
270
        if (!is_array($value)) {
271
            static::reportInvalidArgument(sprintf(
272
                $message ?: 'Expected an array. Got: %s',
273
                static::typeToString($value)
274
            ));
275
        }
276
    }
277
278
    public static function isTraversable($value, $message = '')
279
    {
@@ 298-307 (lines=10) @@
295
        }
296
    }
297
298
    public static function isInstanceOf($value, $class, $message = '')
299
    {
300
        if (!($value instanceof $class)) {
301
            static::reportInvalidArgument(sprintf(
302
                $message ?: 'Expected an instance of %2$s. Got: %s',
303
                static::typeToString($value),
304
                $class
305
            ));
306
        }
307
    }
308
309
    public static function notInstanceOf($value, $class, $message = '')
310
    {
@@ 309-318 (lines=10) @@
306
        }
307
    }
308
309
    public static function notInstanceOf($value, $class, $message = '')
310
    {
311
        if ($value instanceof $class) {
312
            static::reportInvalidArgument(sprintf(
313
                $message ?: 'Expected an instance other than %2$s. Got: %s',
314
                static::typeToString($value),
315
                $class
316
            ));
317
        }
318
    }
319
320
    public static function isEmpty($value, $message = '')
321
    {