diff options
Diffstat (limited to 'languages/utils/CLDRPluralRuleConverterExpression.php')
-rw-r--r-- | languages/utils/CLDRPluralRuleConverterExpression.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/languages/utils/CLDRPluralRuleConverterExpression.php b/languages/utils/CLDRPluralRuleConverterExpression.php new file mode 100644 index 00000000..1ee6b4c5 --- /dev/null +++ b/languages/utils/CLDRPluralRuleConverterExpression.php @@ -0,0 +1,41 @@ +<?php +/** + * @author Niklas Laxström, Tim Starling + * + * @copyright Copyright © 2010-2012, Niklas Laxström + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + * + * @file + * @since 1.20 + */ + +/** + * Helper for CLDRPluralRuleConverter. + * An expression object, representing a region of the input string (for error + * messages), the RPN notation used to evaluate it, and the result type for + * validation. + */ +class CLDRPluralRuleConverterExpression extends CLDRPluralRuleConverterFragment { + /** @var string */ + public $type; + + /** @var string */ + public $rpn; + + function __construct( $parser, $type, $rpn, $pos, $length ) { + parent::__construct( $parser, $pos, $length ); + $this->type = $type; + $this->rpn = $rpn; + } + + public function isType( $type ) { + if ( $type === 'range' && ( $this->type === 'range' || $this->type === 'number' ) ) { + return true; + } + if ( $type === $this->type ) { + return true; + } + + return false; + } +} |