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

PathManipulation   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 35
ccs 10
cts 16
cp 0.625
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A enforceLeadingSlash() 0 4 1
A removeLeadingSlash() 0 4 1
A enforceEndingSlash() 0 4 1
A removeEndingSlash() 0 4 1
A removeWrappingSlashes() 0 4 1
A ensureDirectoryExists() 0 7 2
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