Code Duplication    Length = 12-13 lines in 4 locations

src/Internal/JsonElementReader.php 3 locations

@@ 121-133 (lines=13) @@
118
     *
119
     * @return bool
120
     */
121
    public function nextBoolean(): bool
122
    {
123
        $this->pathIndices[$this->pathIndex]++;
124
125
        if ($this->stackTypes[$this->stackSize - 1] !== JsonToken::BOOLEAN) {
126
            $this->assertionFailed(JsonToken::BOOLEAN);
127
        }
128
129
        /** @var JsonPrimitive $primitive */
130
        $primitive = $this->stack[--$this->stackSize];
131
132
        return $primitive->asBoolean();
133
    }
134
135
    /**
136
     * Consumes the value of the next token, asserts it's a double and returns it
@@ 140-152 (lines=13) @@
137
     *
138
     * @return double
139
     */
140
    public function nextDouble(): float
141
    {
142
        $this->pathIndices[$this->pathIndex]++;
143
144
        if ($this->stackTypes[$this->stackSize - 1] !== JsonToken::NUMBER) {
145
            $this->assertionFailed(JsonToken::NUMBER);
146
        }
147
148
        /** @var JsonPrimitive $primitive */
149
        $primitive = $this->stack[--$this->stackSize];
150
151
        return $primitive->asFloat();
152
    }
153
154
    /**
155
     * Consumes the value of the next token, asserts it's an int and returns it
@@ 159-171 (lines=13) @@
156
     *
157
     * @return int
158
     */
159
    public function nextInteger(): int
160
    {
161
        $this->pathIndices[$this->pathIndex]++;
162
163
        if ($this->stackTypes[$this->stackSize - 1] !== JsonToken::NUMBER) {
164
            $this->assertionFailed(JsonToken::NUMBER);
165
        }
166
167
        /** @var JsonPrimitive $primitive */
168
        $primitive = $this->stack[--$this->stackSize];
169
170
        return $primitive->asInteger();
171
    }
172
173
    /**
174
     * Consumes the value of the next token, asserts it's a string and returns it

src/Internal/JsonReader.php 1 location

@@ 140-151 (lines=12) @@
137
     *
138
     * @return string
139
     */
140
    public function nextName(): string
141
    {
142
        if ($this->stackTypes[$this->stackSize - 1] !== JsonToken::NAME) {
143
            $this->assertionFailed(JsonToken::NAME);
144
        }
145
146
        $name = (string)$this->stack[--$this->stackSize];
147
148
        $this->pathNames[$this->pathIndex] = $name;
149
150
        return $name;
151
    }
152
153
    /**
154
     * Consumes the value of the next token and asserts it's null