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