/** * @dataProvider providerIsNatural */ public function testIsNatural($value, $expected) { $result = Numbers::isNatural($value); $this->assertEquals($expected, $result, "Given: {$value}; Result: ".var_export($result, true)); }
/** * Checks if a value is a natural number excluding zero (e.q. an ID). * * Returns true if and only if the value is a valid natural number excluding the zero. * * @see Numbers::isNatural() * @param mixed Value to check * @return boolean */ public static function naturalNumber($value, $optional) { if (Numbers::isNatural($value) == true) { return true; } else { self::setError(self::ERROR_NATURALNUMBER); return false; } }
/** * Returns the ID used in the last INSERT query. * * null is returned on failure or when there was no last INSERT query. * * @return int ID or null */ public function insertID() { $id = mysql_insert_id($this->connection); return Numbers::isNatural($id) ? $id : null; }