Completed
Push — master ( 5ec81c...d5ea32 )
by Richard
03:52
created

FilePath   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 15
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A getFilePath() 0 4 3
1
<?php
2
namespace Transphporm;
3
4
class FilePath {
5
    private $baseDir;
6
    private $cwd;
0 ignored issues
show
Unused Code introduced by
The property $cwd is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
7
8
    public function __construct(&$baseDir, $customBase = null) {
9
        $this->baseDir = &$baseDir;
10
        if ($customBase === null) $this->customBase = getcwd();
0 ignored issues
show
Bug introduced by
The property customBase does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
11
        else $this->customBase = rtrim($customBase, '/');
12
    }
13
14
    public function getFilePath($filePath = "") {
15
		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase . $filePath;
16
		else return $this->baseDir . $filePath;
17
	}
18
}
19