/** * Returns true if and only if $value only contains digit characters * * @param string $value * @return boolean */ public function isValid($value) { if (!is_string($value) && !is_int($value) && !is_float($value)) { $this->_error(self::INVALID); return false; } $this->_setValue((string) $value); if ('' === $this->_value) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { self::$_filter = new \Zend\Filter\Digits(); } if ($this->_value !== self::$_filter->filter($this->_value)) { $this->_error(self::NOT_DIGITS); return false; } return true; }
/** * Returns true if and only if $value only contains digit characters * * @param string $value * @return bool */ public function isValid($value) { if (!is_string($value) && !is_int($value) && !is_float($value)) { $this->error(self::INVALID); return false; } $this->setValue((string) $value); if ('' === $this->getValue()) { $this->error(self::STRING_EMPTY); return false; } if (null === static::$filter) { static::$filter = new DigitsFilter(); } if ($this->getValue() !== static::$filter->filter($this->getValue())) { $this->error(self::NOT_DIGITS); return false; } return true; }