39 protected static $validators = [
40 'BraceBalance' => BraceBalanceValidator::class,
41 'EscapeCharacter' => EscapeCharacterValidator::class,
42 'GettextNewline' => GettextNewlineValidator::class,
43 'GettextPlural' => GettextPluralValidator::class,
44 'InsertableRegex' => InsertableRegexValidator::class,
45 'InsertableRubyVariable' => InsertableRubyVariableValidator::class,
46 'IosVariable' => IosVariableValidator::class,
47 'MatchSet' => MatchSetValidator::class,
48 'MediaWikiLink' => MediaWikiLinkValidator::class,
49 'MediaWikiPageName' => MediaWikiPageNameValidator::class,
50 'MediaWikiParameter' => MediaWikiParameterValidator::class,
51 'MediaWikiPlural' => MediaWikiPluralValidator::class,
52 'MediaWikiTimeList' => MediaWikiTimeListValidator::class,
53 'Newline' => NewlineValidator::class,
54 'NotEmpty' => NotEmptyValidator::class,
55 'NumericalParameter' => NumericalParameterValidator::class,
56 'Printf' => PrintfValidator::class,
57 'PythonInterpolation' => PythonInterpolationValidator::class,
58 'Replacement' => ReplacementValidator::class,
59 'SmartFormatPlural' => SmartFormatPluralValidator::class,
60 'UnicodePlural' => UnicodePluralValidator::class,
62 'WikiLink' => MediaWikiLinkValidator::class,
64 'WikiParameter' => MediaWikiParameterValidator::class,
75 public static function get( $id, $params = null ) {
76 if ( !isset( self::$validators[ $id ] ) ) {
77 throw new InvalidArgumentException(
"Could not find validator with id - '$id'. " );
92 if ( !class_exists( $class ) ) {
93 throw new InvalidArgumentException(
"Could not find validator class - '$class'. " );
96 return new $class( $params );
105 public static function set( $id, $validator, $ns =
'\\' ) {
106 if ( !class_exists( $ns . $validator ) ) {
107 throw new RuntimeException(
'Could not find validator class - ' . $ns . $validator );
110 self::$validators[ $id ] = $ns . $validator;