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

ReflectionName   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 29
ccs 9
cts 10
cp 0.9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createName() 0 19 4
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