Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

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