protected function parseIntegerField($field, array $arr) { if (!array_key_exists($field, $arr)) { return null; } $value = $arr[$field]; if (!StringUtil::isInteger($value)) { throw new EngineException(sprintf('%s must be integer', ucfirst($field))); } if ($value <= 0) { throw new EngineException(sprintf('%s must be positive', ucfirst($field))); } return $value; }
/** * @dataProvider dpTestIsInteger * @param string $value * @param boolean $expectedResult */ public function testIsInteger($value, $expectedResult) { $assertion = 'assert' . ($expectedResult ? 'True' : 'False'); $this->{$assertion}(StringUtil::isInteger($value)); }