Code Duplication    Length = 9-10 lines in 12 locations

src/Assert.php 12 locations

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