Test Failed
Push — master ( e18acf...2713a2 )
by Marcio
12:48
created

CreateFiles::createWritableFolder()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 3
nc 2
nop 1
1
<?php
2
3
4
namespace Ballybran\Helpers\Stdlib;
5
6
7
use function PHPUnit\Framework\fileExists;
0 ignored issues
show
introduced by
The function PHPUnit\Framework\fileExists was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
8
9
trait CreateFiles
10
{
11
    /**
12
     * @param $file
13
     */
14
    private function createWritableFolder($file)
15
    {
16
        $currPath = '';
17
        $path = explode( "/" , $file );
18
        $currPath .= trim( $path[0] );
19
        if($currPath != '.' && $currPath != '/' ) {
20
            @mkdir( DIR_STORAGE.$currPath , 0777 , true );
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mkdir(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

20
            /** @scrutinizer ignore-unhandled */ @mkdir( DIR_STORAGE.$currPath , 0777 , true );

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
21
        }
22
23
    }
24
}