Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

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