Completed
Push — master ( 22b422...fbd4ac )
by Peter
05:54
created

ReflectionName::createName()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4.016

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 9
cts 10
cp 0.9
rs 9.2
cc 4
eloc 9
nc 4
nop 1
crap 4.016
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL, Commercial license.
5
 *
6
 * @package maslosoft/addendum
7
 * @licence AGPL, Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes)
9
 * @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes)
10
 * @copyright Copyright (c) Jan Suchal (Original version, builder, parser)
11
 * @link http://maslosoft.com/addendum/ - maslosoft addendum
12
 * @link https://code.google.com/p/addendum/ - original addendum project
13
 */
14
15
namespace Maslosoft\Addendum\Utilities;
16
17
use ReflectionClass;
18
use ReflectionMethod;
19
use ReflectionProperty;
20
21
/**
22
 * ReflectionName
23
 *
24
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
25
 */
26
class ReflectionName
27
{
28
29
	/**
30
	 * Create class name
31
	 * @param ReflectionClass|ReflectionMethod|ReflectionProperty|bool $target
32
	 * @return string
33
	 */
34 47
	public static function createName($target)
35
	{
36 47
		if (!$target)
37 47
		{
38
			return 'unknown';
39
		}
40 47
		if ($target instanceof ReflectionMethod)
41 47
		{
42 8
			return $target->getDeclaringClass()->name . '@' . $target->name . '()';
43
		}
44 47
		elseif ($target instanceof ReflectionProperty)
45
		{
46 21
			return $target->getDeclaringClass()->name . '@$' . $target->name;
47
		}
48
		else
49
		{
50 47
			return $target->name;
51
		}
52
	}
53
54
}
55