Code Duplication    Length = 21-21 lines in 2 locations

src/Backup/Path.php 1 location

@@ 91-111 (lines=21) @@
88
     *
89
     * @param string $path
90
     */
91
    private function detectPathNotChanging(string $path)
92
    {
93
        $partsNotChanging     = [];
94
        $foundChangingElement = false;
95
96
        foreach (Util\Path::getDirectoryListFromAbsolutePath($path) as $depth => $dir) {
97
            $this->pathElements[] = $dir;
98
99
            // already found placeholder or found one right now
100
            // path isn't static anymore so don't add directory to path not changing
101
            if ($foundChangingElement || Util\Path::isContainingPlaceholder($dir)) {
102
                $foundChangingElement = true;
103
                continue;
104
            }
105
            // do not add the / element leading slash will be re-added later
106
            if ($dir !== '/') {
107
                $partsNotChanging[] = $dir;
108
            }
109
        }
110
        $this->pathNotChanging = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $partsNotChanging);
111
    }
112
113
    /**
114
     * Return path element at given index.

src/Backup/Target.php 1 location

@@ 189-209 (lines=21) @@
186
     *
187
     * @param string $path
188
     */
189
    private function detectPathNotChanging(string $path)
190
    {
191
        $partsNotChanging     = [];
192
        $foundChangingElement = false;
193
194
        foreach (Util\Path::getDirectoryListFromAbsolutePath($path) as $depth => $dir) {
195
            $this->pathElements[] = $dir;
196
197
            // already found placeholder or found one right now
198
            // path isn't static anymore so don't add directory to path not changing
199
            if ($foundChangingElement || Util\Path::isContainingPlaceholder($dir)) {
200
                $foundChangingElement = true;
201
                continue;
202
            }
203
            // do not add the / element leading slash will be re-added later
204
            if ($dir !== '/') {
205
                $partsNotChanging[] = $dir;
206
            }
207
        }
208
        $this->pathNotChanging = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $partsNotChanging);
209
    }
210
211
    /**
212
     * Filename setter.