Completed
Push — master ( b49095...171799 )
by Nicolas
05:32
created

PathManipulation::enforceLeadingSlash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Puzzle\Pieces;
4
5
trait PathManipulation
6
{
7 16
    private function enforceLeadingSlash($path)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
8
    {
9 16
        return DIRECTORY_SEPARATOR . $this->removeLeadingSlash($path);
10
    }
11
12 32
    private function removeLeadingSlash($path)
13
    {
14 32
        return ltrim($path, DIRECTORY_SEPARATOR);
15
    }
16
17 16
    private function enforceEndingSlash($path)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
18
    {
19 16
        return $this->removeEndingSlash($path) . DIRECTORY_SEPARATOR;
20
    }
21
22 32
    private function removeEndingSlash($path)
23
    {
24 32
        return rtrim($path, DIRECTORY_SEPARATOR);
25
    }
26
27 16
    private function removeWrappingSlashes($path)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
28
    {
29 16
        return trim($path, DIRECTORY_SEPARATOR);
30
    }
31
    
32
    private function ensureDirectoryExists($path)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
33
    {
34
        if(! is_dir($path))
35
        {
36
            mkdir($path, 0777, true);
37
        }
38
    }
39
}
40