| @@ 211-225 (lines=15) @@ | ||
| 208 | * @return string |
|
| 209 | * @throws \Tebru\Gson\Exception\UnexpectedJsonTokenException If the next token is not NAME or STRING |
|
| 210 | */ |
|
| 211 | public function nextString(): string |
|
| 212 | { |
|
| 213 | $peek = $this->peek(); |
|
| 214 | if ($peek === JsonToken::NAME) { |
|
| 215 | return $this->nextName(); |
|
| 216 | } |
|
| 217 | ||
| 218 | $this->expect(JsonToken::STRING); |
|
| 219 | ||
| 220 | $result = (string)$this->pop(); |
|
| 221 | ||
| 222 | $this->incrementPathIndex(); |
|
| 223 | ||
| 224 | return $result; |
|
| 225 | } |
|
| 226 | ||
| 227 | /** |
|
| 228 | * Consumes the value of the next token and asserts it's null |
|
| @@ 217-232 (lines=16) @@ | ||
| 214 | * @return string |
|
| 215 | * @throws \Tebru\Gson\Exception\UnexpectedJsonTokenException If the next token is not NAME or STRING |
|
| 216 | */ |
|
| 217 | public function nextString(): string |
|
| 218 | { |
|
| 219 | $peek = $this->peek(); |
|
| 220 | if ($peek === JsonToken::NAME) { |
|
| 221 | return $this->nextName(); |
|
| 222 | } |
|
| 223 | ||
| 224 | $this->expect(JsonToken::STRING); |
|
| 225 | ||
| 226 | /** @var JsonPrimitive $primitive */ |
|
| 227 | $primitive = $this->pop(); |
|
| 228 | ||
| 229 | $this->incrementPathIndex(); |
|
| 230 | ||
| 231 | return $primitive->asString(); |
|
| 232 | } |
|
| 233 | ||
| 234 | /** |
|
| 235 | * Consumes the value of the next token and asserts it's null |
|