Debian Codegraph @

vendor/wikimedia/cldr-plural-rule-parser/src/Converter/Expression.php

raw
1 <?php
2 /**
3 * @author Niklas Laxström, Tim Starling
4 * @license GPL-2.0-or-later
5 * @file
6 */
7
8 namespace CLDRPluralRuleParser\Converter;
9
10 use CLDRPluralRuleParser\Converter;
11
12 /**
13 * Helper for Converter.
14 * An expression object, representing a region of the input string (for error
15 * messages), the RPN notation used to evaluate it, and the result type for
16 * validation.
17 */
18 class Expression extends Fragment {
19 /** @var string */
20 public $type;
21
22 /** @var string */
23 public $rpn;
24
25 /**
26 * @param Converter $parser
27 * @param string $type
28 * @param string $rpn
29 * @param int $pos
30 * @param int $length
31 */
32 public function __construct( Converter $parser, $type, $rpn, $pos, $length ) {
33 parent::__construct( $parser, $pos, $length );
34 $this->type = $type;
35 $this->rpn = $rpn;
36 }
37
38 /**
39 * @param string $type
40 * @return bool
41 */
42 public function isType( $type ): bool {
43 if ( $type === 'range' && ( $this->type === 'range' || $this->type === 'number' ) ) {
44 return true;
45 }
46 if ( $type === $this->type ) {
47 return true;
48 }
49
50 return false;
51 }
52 }