/** * 2015-04-05 * @used-by resolve() * @param string $name * @param bool $skipOnNull [optional] * @return \Zend_Validate_Interface|\Zend_Filter_Interface */ private static function byName($name, $skipOnNull = false) { /** @var array(bool => array(string => \Zend_Validate_Interface)) */ static $cache; if (!isset($cache[$skipOnNull][$name])) { /** @var array(string => string) $map */ static $map; if (!$map) { /** @var string[] $entries */ $entries = [DF_F_TRIM, DF_V_ARRAY, DF_V_BOOL, DF_V_FLOAT, DF_V_INT, DF_V_ISO2, DF_V_NAT, DF_V_NAT0, DF_V_STRING, DF_V_STRING_NE]; $map = array_combine($entries, $entries); } /** @var \Zend_Validate_Interface|\Zend_Filter_Interface $result */ if (isset($map[$name])) { $result = new $map[$name](); } else { if (df_class_exists($name) || @interface_exists($name)) { $result = \Df\Zf\Validate\ClassT::i($name); } else { df_error("Система не смогла распознать валидатор «{$name}»."); } } $result->{self::$SKIP_ON_NULL} = $skipOnNull; $cache[$skipOnNull][$name] = $result; } return $cache[$skipOnNull][$name]; }
/** * @param mixed $resultValue * @param string $className * @param int $stackLevel [optional] * @return void * @throws \Exception */ public static function validateResultClass($resultValue, $className, $stackLevel = 0) { self::validateResult(\Df\Zf\Validate\ClassT::s($className), $resultValue, $stackLevel + 1); }