Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

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