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

FilePath::getFilePath()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 3
eloc 3
nc 2
nop 1
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