Code Duplication    Length = 18-23 lines in 2 locations

src/allejo/stakx/System/Filesystem.php 1 location

@@ 208-225 (lines=18) @@
205
     *
206
     * @return SplFileInfo A reference to the newly created file
207
     */
208
    public function writeFile ($targetDir, $fileName, $content)
209
    {
210
        $outputFolder = $this->getFolderPath($this->absolutePath($targetDir, $fileName));
211
        $targetFile   = $this->getFileName($fileName);
212
213
        if (!file_exists($outputFolder))
214
        {
215
            mkdir($outputFolder, 0755, true);
216
        }
217
218
        file_put_contents($this->appendPath($outputFolder, $targetFile), $content, LOCK_EX);
219
220
        return (new SplFileInfo(
221
            $fileName,
222
            $this->absolutePath($targetDir),
223
            $this->absolutePath($targetDir, $fileName))
224
        );
225
    }
226
}

src/allejo/stakx/System/Folder.php 1 location

@@ 99-121 (lines=23) @@
96
     * @since 0.1.0
97
     * @return SplFileInfo
98
     */
99
    public function writeFile ($relativePath, $content)
100
    {
101
        $outputFolder   = $this->fs->getFolderPath($relativePath);
102
        $targetFileName = $this->fs->getFileName($outputFolder);
103
104
        $absoluteFolderPath = $this->buildPath($this->getCwd(), $outputFolder);
105
106
        if (!file_exists($absoluteFolderPath))
107
        {
108
            mkdir($absoluteFolderPath, 0755, true);
109
        }
110
111
        file_put_contents(
112
            $this->buildPath($this->getCwd(), $relativePath),
113
            $content
114
        );
115
116
        return (new SplFileInfo(
117
            $targetFileName,
118
            $absoluteFolderPath,
119
            $this->buildPath($absoluteFolderPath, $targetFileName)
120
        ));
121
    }
122
123
    /**
124
     * @param string $pathFragments