AbstractFileWriter::createDirectory()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\FactFinderSdk\Business\Writer;
9
10
abstract class AbstractFileWriter
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $fileName;
16
17
    /**
18
     * @param string $filePath
19
     * @param array $data
20
     * @param bool $append
21
     *
22
     * @return void
23
     */
24
    abstract public function write($filePath, $data, $append = false);
25
26
    /**
27
     * @param string $fileName
28
     *
29
     * @return void
30
     */
31
    protected function createDirectory($fileName)
32
    {
33
        $pathInfo = pathinfo($fileName);
34
        $directory = $pathInfo['dirname'];
35
36
        if (!file_exists($directory)) {
37
            mkdir($directory);
38
        }
39
    }
40
}
41