/** * checkType controleert de gegeven waarde tegen het gegeven type * * @access private * @param variant $p_vValue de waarde * @param int $p_nType Het te controleren type * @return int het resultaat van de controle (RESULT_OK, RESULT_INVALID) */ private function checkType($p_vValue, $p_nType) { $nResult = self::RESULT_INVALID; try { switch ($p_nType) { case self::TYPE_STRING: if (is_string($p_vValue)) { $nResult = self::RESULT_OK; } else { if (is_numeric($p_vValue)) { $nResult = self::RESULT_CONVERTABLE; } } break; case self::TYPE_BOOLEAN: if (is_bool($p_vValue)) { $nResult = self::RESULT_OK; } else { // convertable als het 1 of 0 bevat if (is_numeric($p_vValue) && (intVal($p_vValue) == 1 || intVal($p_vValue) == 0)) { $nResult = self::RESULT_CONVERTABLE; } } break; case self::TYPE_INT: if (is_int($p_vValue)) { $nResult = self::RESULT_OK; } else { // convertable als het een getal bevat if (is_numeric($p_vValue)) { $nResult = self::RESULT_CONVERTABLE; } } break; case self::TYPE_FLOAT: if (is_float($p_vValue)) { $nResult = self::RESULT_OK; } else { // convertable als het een getal bevat if (is_numeric($p_vValue)) { $nResult = self::RESULT_CONVERTABLE; } } break; case self::TYPE_ARRAY: if (is_array($p_vValue)) { $nResult = self::RESULT_OK; } break; case self::TYPE_URL: if (CheckLib::checkURL($p_vValue)) { $nResult = self::RESULT_OK; } break; case self::TYPE_EMAIL: if (CheckLib::checkEmail($p_vValue)) { $nResult = self::RESULT_OK; } break; case self::TYPE_ZIPCODE: if (CheckLib::checkDutchZipcode($p_vValue)) { $nResult = self::RESULT_OK; } break; case self::TYPE_PLAINTEXT: if (CheckLib::checkPlainText($p_vValue)) { $nResult = self::RESULT_OK; } break; case self::TYPE_ALPHATEXT: if (CheckLib::checkAlphaText($p_vValue)) { $nResult = self::RESULT_OK; } break; case self::TYPE_PHONE: if (CheckLib::checkPhoneNumber($p_vValue)) { $nResult = self::RESULT_OK; } break; default: // resultaat invalid } } catch (Exception $e) { // bij een fout wordt het resultaat invalid $nResult = self::RESULT_INVALID; } return $nResult; }