Merge "jshint: Enable 'es3' option"
[lhc/web/wiklou.git] / languages / utils / CLDRPluralRuleConverter_Fragment.php
1 <?php
2
3 /**
4 * @author Niklas Laxström, Tim Starling
5 *
6 * @copyright Copyright © 2010-2012, Niklas Laxström
7 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8 *
9 * @file
10 * @since 1.20
11 */
12
13 /**
14 * Helper for CLDRPluralRuleConverter.
15 * The base class for operators and expressions, describing a region of the input string.
16 */
17 class CLDRPluralRuleConverter_Fragment {
18 public $parser, $pos, $length, $end;
19
20 function __construct( $parser, $pos, $length ) {
21 $this->parser = $parser;
22 $this->pos = $pos;
23 $this->length = $length;
24 $this->end = $pos + $length;
25 }
26
27 public function error( $message ) {
28 $text = $this->getText();
29 throw new CLDRPluralRuleError( "$message at position " . ( $this->pos + 1 ) . ": \"$text\"" );
30 }
31
32 public function getText() {
33 return substr( $this->parser->rule, $this->pos, $this->length );
34 }
35 }