Reflector::classPath()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 17
rs 10
ccs 0
cts 9
cp 0
cc 3
nc 4
nop 2
crap 12
1
<?php
2
3
namespace ElegantMedia\PHPToolkit;
4
5
class Reflector
6
{
7
	/**
8
	 * Get the inherited class' directory path.
9
	 *
10
	 * @param object|string $self
11
	 * @param null          $pathSuffix
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $pathSuffix is correct as it would always require null to be passed?
Loading history...
12
	 *
13
	 * @return string
14
	 *
15
	 * @throws \ReflectionException
16
	 */
17
	public static function classPath($self, $pathSuffix = null): string
18
	{
19
		$class = $self;
20
21
		if (is_object($self)) {
22
			$class = get_class($self);
23
		}
24
25
		$reflector = new \ReflectionClass($class);
26
27
		$path = dirname($reflector->getFileName());
28
29
		if ($pathSuffix) {
0 ignored issues
show
introduced by
$pathSuffix is of type null, thus it always evaluated to false.
Loading history...
30
			$path .= DIRECTORY_SEPARATOR . ltrim($pathSuffix, DIRECTORY_SEPARATOR);
31
		}
32
33
		return Path::canonical($path);
34
	}
35
}
36