Code Duplication    Length = 18-23 lines in 2 locations

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

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

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

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