Completed
Push — master ( 522585...279d2c )
by Harry
04:14
created

MakeDirectory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 3
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A makeDirectory() 0 11 3
1
<?php
2
3
namespace Graze\DataFile\Modify;
4
5
use Graze\DataFile\Modify\Exception\MakeDirectoryFailedException;
6
use Graze\DataFile\Node\FileNode;
7
use Graze\DataFile\Node\LocalFile;
8
9
class MakeDirectory
10
{
11
    const VISIBILITY_PUBLIC  = 'public';
12
    const VISIBILITY_PRIVATE = 'private';
13
14
    /**
15
     * Create the directory specified by the $file if it does not exist
16
     *
17
     * @param FileNode $file
18
     * @param string   $visibility public or private visibility
0 ignored issues
show
Documentation introduced by
Should the type for parameter $visibility not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
19
     *
20
     * @return LocalFile The original file inputted
21
     * @throws MakeDirectoryFailedException
22
     */
23 9
    public function makeDirectory(FileNode $file, $visibility = null)
24
    {
25 9
        $madeDirectory = $file->getFilesystem()->createDir($file->getDirectory(), [
26 9
            'visibility' => $visibility ?: static::VISIBILITY_PUBLIC,
27
        ]);
28 9
        if (!$madeDirectory) {
29 1
            throw new MakeDirectoryFailedException($file, error_get_last()['message']);
30
        }
31
32 8
        return $file;
33
    }
34
}
35