Code Duplication    Length = 15-15 lines in 2 locations

src/Internal/JsonDecodeReader.php 1 location

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

src/Internal/JsonElementReader.php 1 location

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