for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
*
* This file is part of Aura for PHP.
* @license http://opensource.org/licenses/bsd-license.php BSD
*/
namespace Aura\Filter\Rule\Validate;
* Validates that the value represents an integer.
* @package Aura.Filter
class Integer
{
* @param object $subject The subject to be filtered.
* @param string $field The subject field name.
* @return bool True if valid, false if not.
public function __invoke($subject, $field)
$value = $subject->$field;
if (is_int($value)) {
return true;
}
// otherwise, must be numeric, and must be same as when cast to int
return is_numeric($value) && $value == (int) $value;