Code Duplication    Length = 15-15 lines in 2 locations

src/Internal/JsonDecodeReader.php 1 location

@@ 209-223 (lines=15) @@
206
     *
207
     * @return string
208
     */
209
    public function getPath(): string
210
    {
211
        $result = '$';
212
        foreach ($this->stack as $index => $item) {
213
            if ($item instanceof ArrayIterator && isset($this->pathIndices[$index])) {
214
                $result .= '['.$this->pathIndices[$index].']';
215
            }
216
217
            if ($item instanceof StdClassIterator && isset($this->pathNames[$index])) {
218
                $result .= '.'.$this->pathNames[$index];
219
            }
220
        }
221
222
        return $result;
223
    }
224
225
    /**
226
     * Push an element onto the stack

src/Internal/JsonElementReader.php 1 location

@@ 214-228 (lines=15) @@
211
     *
212
     * @return string
213
     */
214
    public function getPath(): string
215
    {
216
        $result = '$';
217
        foreach ($this->stack as $index => $item) {
218
            if ($item instanceof ArrayIterator && isset($this->pathIndices[$index])) {
219
                $result .= '['.$this->pathIndices[$index].']';
220
            }
221
222
            if ($item instanceof JsonObjectIterator && isset($this->pathNames[$index])) {
223
                $result .= '.'.$this->pathNames[$index];
224
            }
225
        }
226
227
        return $result;
228
    }
229
230
    /**
231
     * Push an element onto the stack