Code Duplication    Length = 15-15 lines in 2 locations

src/Internal/JsonDecodeReader.php 1 location

@@ 202-216 (lines=15) @@
199
     * @return string
200
     * @throws \Tebru\Gson\Exception\UnexpectedJsonTokenException If the next token is not NAME or STRING
201
     */
202
    public function nextString(): string
203
    {
204
        $peek = $this->peek();
205
        if ($peek === JsonToken::NAME) {
206
            return $this->nextName();
207
        }
208
209
        if ($peek !== JsonToken::STRING) {
210
            throw new UnexpectedJsonTokenException(
211
                sprintf('Expected "%s", but found "%s"', JsonToken::STRING, $this->peek())
212
            );
213
        }
214
215
        return $this->pop();
216
    }
217
218
    /**
219
     * Consumes the value of the next token and asserts it's null

src/Internal/JsonElementReader.php 1 location

@@ 208-222 (lines=15) @@
205
     * @return string
206
     * @throws \Tebru\Gson\Exception\UnexpectedJsonTokenException If the next token is not NAME or STRING
207
     */
208
    public function nextString(): string
209
    {
210
        $peek = $this->peek();
211
        if ($peek === JsonToken::NAME) {
212
            return $this->nextName();
213
        }
214
215
        if ($peek !== JsonToken::STRING) {
216
            throw new UnexpectedJsonTokenException(
217
                sprintf('Expected "%s", but found "%s"', JsonToken::STRING, $this->peek())
218
            );
219
        }
220
221
        return $this->pop()->asString();
222
    }
223
224
    /**
225
     * Consumes the value of the next token and asserts it's null