| @@ 178-186 (lines=9) @@ | ||
| 175 | static::notEq($value, '', $message); |
|
| 176 | } |
|
| 177 | ||
| 178 | public static function integer($value, $message = '') |
|
| 179 | { |
|
| 180 | if (!is_int($value)) { |
|
| 181 | static::reportInvalidArgument(sprintf( |
|
| 182 | $message ?: 'Expected an integer. Got: %s', |
|
| 183 | static::typeToString($value) |
|
| 184 | )); |
|
| 185 | } |
|
| 186 | } |
|
| 187 | ||
| 188 | public static function integerish($value, $message = '') |
|
| 189 | { |
|
| @@ 188-196 (lines=9) @@ | ||
| 185 | } |
|
| 186 | } |
|
| 187 | ||
| 188 | public static function integerish($value, $message = '') |
|
| 189 | { |
|
| 190 | if (!is_numeric($value) || $value != (int) $value) { |
|
| 191 | static::reportInvalidArgument(sprintf( |
|
| 192 | $message ?: 'Expected an integerish value. Got: %s', |
|
| 193 | static::typeToString($value) |
|
| 194 | )); |
|
| 195 | } |
|
| 196 | } |
|
| 197 | ||
| 198 | public static function float($value, $message = '') |
|
| 199 | { |
|
| @@ 198-206 (lines=9) @@ | ||
| 195 | } |
|
| 196 | } |
|
| 197 | ||
| 198 | public static function float($value, $message = '') |
|
| 199 | { |
|
| 200 | if (!is_float($value)) { |
|
| 201 | static::reportInvalidArgument(sprintf( |
|
| 202 | $message ?: 'Expected a float. Got: %s', |
|
| 203 | static::typeToString($value) |
|
| 204 | )); |
|
| 205 | } |
|
| 206 | } |
|
| 207 | ||
| 208 | public static function numeric($value, $message = '') |
|
| 209 | { |
|
| @@ 208-216 (lines=9) @@ | ||
| 205 | } |
|
| 206 | } |
|
| 207 | ||
| 208 | public static function numeric($value, $message = '') |
|
| 209 | { |
|
| 210 | if (!is_numeric($value)) { |
|
| 211 | static::reportInvalidArgument(sprintf( |
|
| 212 | $message ?: 'Expected a numeric. Got: %s', |
|
| 213 | static::typeToString($value) |
|
| 214 | )); |
|
| 215 | } |
|
| 216 | } |
|
| 217 | ||
| 218 | public static function natural($value, $message = '') |
|
| 219 | { |
|
| @@ 228-236 (lines=9) @@ | ||
| 225 | } |
|
| 226 | } |
|
| 227 | ||
| 228 | public static function boolean($value, $message = '') |
|
| 229 | { |
|
| 230 | if (!is_bool($value)) { |
|
| 231 | static::reportInvalidArgument(sprintf( |
|
| 232 | $message ?: 'Expected a boolean. Got: %s', |
|
| 233 | static::typeToString($value) |
|
| 234 | )); |
|
| 235 | } |
|
| 236 | } |
|
| 237 | ||
| 238 | public static function scalar($value, $message = '') |
|
| 239 | { |
|
| @@ 238-246 (lines=9) @@ | ||
| 235 | } |
|
| 236 | } |
|
| 237 | ||
| 238 | public static function scalar($value, $message = '') |
|
| 239 | { |
|
| 240 | if (!is_scalar($value)) { |
|
| 241 | static::reportInvalidArgument(sprintf( |
|
| 242 | $message ?: 'Expected a scalar. Got: %s', |
|
| 243 | static::typeToString($value) |
|
| 244 | )); |
|
| 245 | } |
|
| 246 | } |
|
| 247 | ||
| 248 | public static function object($value, $message = '') |
|
| 249 | { |
|
| @@ 248-256 (lines=9) @@ | ||
| 245 | } |
|
| 246 | } |
|
| 247 | ||
| 248 | public static function object($value, $message = '') |
|
| 249 | { |
|
| 250 | if (!is_object($value)) { |
|
| 251 | static::reportInvalidArgument(sprintf( |
|
| 252 | $message ?: 'Expected an object. Got: %s', |
|
| 253 | static::typeToString($value) |
|
| 254 | )); |
|
| 255 | } |
|
| 256 | } |
|
| 257 | ||
| 258 | public static function resource($value, $type = null, $message = '') |
|
| 259 | { |
|
| @@ 276-284 (lines=9) @@ | ||
| 273 | } |
|
| 274 | } |
|
| 275 | ||
| 276 | public static function isCallable($value, $message = '') |
|
| 277 | { |
|
| 278 | if (!is_callable($value)) { |
|
| 279 | static::reportInvalidArgument(sprintf( |
|
| 280 | $message ?: 'Expected a callable. Got: %s', |
|
| 281 | static::typeToString($value) |
|
| 282 | )); |
|
| 283 | } |
|
| 284 | } |
|
| 285 | ||
| 286 | public static function isArray($value, $message = '') |
|
| 287 | { |
|
| @@ 286-294 (lines=9) @@ | ||
| 283 | } |
|
| 284 | } |
|
| 285 | ||
| 286 | public static function isArray($value, $message = '') |
|
| 287 | { |
|
| 288 | if (!is_array($value)) { |
|
| 289 | static::reportInvalidArgument(sprintf( |
|
| 290 | $message ?: 'Expected an array. Got: %s', |
|
| 291 | static::typeToString($value) |
|
| 292 | )); |
|
| 293 | } |
|
| 294 | } |
|
| 295 | ||
| 296 | public static function isTraversable($value, $message = '') |
|
| 297 | { |
|
| @@ 334-343 (lines=10) @@ | ||
| 331 | } |
|
| 332 | } |
|
| 333 | ||
| 334 | public static function isInstanceOf($value, $class, $message = '') |
|
| 335 | { |
|
| 336 | if (!($value instanceof $class)) { |
|
| 337 | static::reportInvalidArgument(sprintf( |
|
| 338 | $message ?: 'Expected an instance of %2$s. Got: %s', |
|
| 339 | static::typeToString($value), |
|
| 340 | $class |
|
| 341 | )); |
|
| 342 | } |
|
| 343 | } |
|
| 344 | ||
| 345 | public static function notInstanceOf($value, $class, $message = '') |
|
| 346 | { |
|
| @@ 345-354 (lines=10) @@ | ||
| 342 | } |
|
| 343 | } |
|
| 344 | ||
| 345 | public static function notInstanceOf($value, $class, $message = '') |
|
| 346 | { |
|
| 347 | if ($value instanceof $class) { |
|
| 348 | static::reportInvalidArgument(sprintf( |
|
| 349 | $message ?: 'Expected an instance other than %2$s. Got: %s', |
|
| 350 | static::typeToString($value), |
|
| 351 | $class |
|
| 352 | )); |
|
| 353 | } |
|
| 354 | } |
|
| 355 | ||
| 356 | public static function isEmpty($value, $message = '') |
|
| 357 | { |
|