| @@ 125-139 (lines=15) @@ | ||
| 122 | * @return string |
|
| 123 | * @throws \Tebru\Gson\Exception\UnexpectedJsonTokenException If the next token is not NAME or STRING |
|
| 124 | */ |
|
| 125 | public function nextString(): string |
|
| 126 | { |
|
| 127 | $peek = $this->peek(); |
|
| 128 | if ($peek === JsonToken::NAME) { |
|
| 129 | return $this->nextName(); |
|
| 130 | } |
|
| 131 | ||
| 132 | $this->expect(JsonToken::STRING); |
|
| 133 | ||
| 134 | $result = (string)$this->pop(); |
|
| 135 | ||
| 136 | $this->incrementPathIndex(); |
|
| 137 | ||
| 138 | return $result; |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * Returns an enum representing the type of the next token without consuming it |
|
| @@ 129-144 (lines=16) @@ | ||
| 126 | * @return string |
|
| 127 | * @throws \Tebru\Gson\Exception\UnexpectedJsonTokenException If the next token is not NAME or STRING |
|
| 128 | */ |
|
| 129 | public function nextString(): string |
|
| 130 | { |
|
| 131 | $peek = $this->peek(); |
|
| 132 | if ($peek === JsonToken::NAME) { |
|
| 133 | return $this->nextName(); |
|
| 134 | } |
|
| 135 | ||
| 136 | $this->expect(JsonToken::STRING); |
|
| 137 | ||
| 138 | /** @var JsonPrimitive $primitive */ |
|
| 139 | $primitive = $this->pop(); |
|
| 140 | ||
| 141 | $this->incrementPathIndex(); |
|
| 142 | ||
| 143 | return $primitive->asString(); |
|
| 144 | } |
|
| 145 | ||
| 146 | /** |
|
| 147 | * Returns an enum representing the type of the next token without consuming it |
|