Code Duplication    Length = 18-24 lines in 2 locations

src/System/Folder.php 1 location

@@ 84-107 (lines=24) @@
81
     * @param string $targetPath
82
     * @param string $fileContent
83
     */
84
    public function writeFile ($targetPath, $fileContent)
85
    {
86
        $outputFolder   = $this->fs->getFolderPath($targetPath);
87
        $targetFileName = $this->fs->getFileName($outputFolder);
88
89
        $absoluteFolderPath = $this->buildPath($this->getCwd(), $outputFolder);
90
91
        if (!file_exists($absoluteFolderPath))
92
        {
93
            mkdir($absoluteFolderPath, 0755, true);
94
        }
95
96
        file_put_contents(
97
            $this->buildPath($this->getCwd(), $targetPath),
98
            $fileContent,
99
            LOCK_EX
100
        );
101
102
        return (new SplFileInfo(
103
            $targetFileName,
104
            $absoluteFolderPath,
105
            $this->buildPath($absoluteFolderPath, $targetFileName)
106
        ));
107
    }
108
109
    /**
110
     * @param string $pathFragments

src/System/FileSystem.php 1 location

@@ 228-245 (lines=18) @@
225
     *
226
     * @return SplFileInfo A reference to the newly created file
227
     */
228
    public function writeFile ($targetDir, $fileName, $content)
229
    {
230
        $outputFolder = $this->getFolderPath($this->absolutePath($targetDir, $fileName));
231
        $targetFile   = $this->getFileName($fileName);
232
233
        if (!file_exists($outputFolder))
234
        {
235
            mkdir($outputFolder, 0755, true);
236
        }
237
238
        file_put_contents($this->appendPath($outputFolder, $targetFile), $content, LOCK_EX);
239
240
        return (new SplFileInfo(
241
            $fileName,
242
            $this->absolutePath($targetDir),
243
            $this->absolutePath($targetDir, $fileName))
244
        );
245
    }
246
}