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