@@ 139-161 (lines=23) @@ | ||
136 | /** |
|
137 | * @inheritdoc |
|
138 | */ |
|
139 | public function parseInt($data, $path) |
|
140 | { |
|
141 | $this->setPath($path); |
|
142 | ||
143 | $pathValue = null; |
|
144 | if ($this->hasValue($data, $path)) { |
|
145 | $value = $this->getValue($data, $path); |
|
146 | if ((null === $value) || (is_int($value))) { |
|
147 | $pathValue = $value; |
|
148 | } elseif (is_numeric($value)) { |
|
149 | $pathValue = (int) $value; |
|
150 | } else { |
|
151 | throw new \InvalidArgumentException( |
|
152 | sprintf("Value expected to be an integer, but %s given", gettype($value)), |
|
153 | 400 |
|
154 | ); |
|
155 | } |
|
156 | } |
|
157 | ||
158 | $this->restorePath(); |
|
159 | ||
160 | return $pathValue; |
|
161 | } |
|
162 | ||
163 | /** |
|
164 | * @inheritdoc |
|
@@ 166-188 (lines=23) @@ | ||
163 | /** |
|
164 | * @inheritdoc |
|
165 | */ |
|
166 | public function parseFloat($data, $path) |
|
167 | { |
|
168 | $this->setPath($path); |
|
169 | ||
170 | $pathValue = null; |
|
171 | if ($this->hasValue($data, $path)) { |
|
172 | $value = $this->getValue($data, $path); |
|
173 | if ((null === $value) || (is_float($value))) { |
|
174 | $pathValue = $value; |
|
175 | } elseif (is_numeric($pathValue)) { |
|
176 | $pathValue = (float) $value; |
|
177 | } else { |
|
178 | throw new \InvalidArgumentException( |
|
179 | sprintf("Value expected to be a float, but %s given", gettype($value)), |
|
180 | 400 |
|
181 | ); |
|
182 | } |
|
183 | } |
|
184 | ||
185 | $this->restorePath(); |
|
186 | ||
187 | return $pathValue; |
|
188 | } |
|
189 | ||
190 | /** |
|
191 | * @inheritdoc |