Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / I18n / Translator / Plural / Symbol.php
blobd5e2b3c1145b011ce2ae7c97e5098ced8957b517
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\I18n\Translator\Plural;
12 use Closure;
13 use Zend\I18n\Exception;
15 /**
16 * Parser symbol.
18 * All properties in the symbol are defined as public for easier and faster
19 * access from the applied closures. An exception are the closure properties
20 * themselves, as they have to be accessed via the appropriate getter and
21 * setter methods.
23 class Symbol
25 /**
26 * Parser instance.
28 * @var Parser
30 public $parser;
32 /**
33 * Node or token type name.
35 * @var string
37 public $id;
39 /**
40 * Left binding power (precedence).
42 * @var int
44 public $leftBindingPower;
46 /**
47 * Getter for null denotation.
49 * @var callable
51 protected $nullDenotationGetter;
53 /**
54 * Getter for left denotation.
56 * @var callable
58 protected $leftDenotationGetter;
60 /**
61 * Value used by literals.
63 * @var mixed
65 public $value;
67 /**
68 * First node value.
70 * @var Symbol
72 public $first;
74 /**
75 * Second node value.
77 * @var Symbol
79 public $second;
81 /**
82 * Third node value.
84 * @var Symbol
86 public $third;
88 /**
89 * Create a new symbol.
91 * @param Parser $parser
92 * @param string $id
93 * @param int $leftBindingPower
95 public function __construct(Parser $parser, $id, $leftBindingPower)
97 $this->parser = $parser;
98 $this->id = $id;
99 $this->leftBindingPower = $leftBindingPower;
103 * Set the null denotation getter.
105 * @param Closure $getter
106 * @return Symbol
108 public function setNullDenotationGetter(Closure $getter)
110 $this->nullDenotationGetter = $getter;
111 return $this;
115 * Set the left denotation getter.
117 * @param Closure $getter
118 * @return Symbol
120 public function setLeftDenotationGetter(Closure $getter)
122 $this->leftDenotationGetter = $getter;
123 return $this;
127 * Get null denotation.
129 * @throws Exception\ParseException
130 * @return Symbol
132 public function getNullDenotation()
134 if ($this->nullDenotationGetter === null) {
135 throw new Exception\ParseException(sprintf(
136 'Syntax error: %s', $this->id
140 /** @var callable $function */
141 $function = $this->nullDenotationGetter;
142 return $function($this);
146 * Get left denotation.
148 * @param Symbol $left
149 * @throws Exception\ParseException
150 * @return Symbol
152 public function getLeftDenotation($left)
154 if ($this->leftDenotationGetter === null) {
155 throw new Exception\ParseException(sprintf(
156 'Unknown operator: %s', $this->id
160 /** @var callable $function */
161 $function = $this->leftDenotationGetter;
162 return $function($this, $left);