Code Duplication    Length = 9-10 lines in 11 locations

src/Assert.php 11 locations

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