1 | <?php |
||
26 | class ClassReflection implements Reflection, ResultConvertible |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * @var \Zend\Code\Reflection\ClassReflection |
||
31 | */ |
||
32 | private $reflection; |
||
33 | |||
34 | |||
35 | /** |
||
36 | * @param string $className |
||
37 | */ |
||
38 | public function __construct($className) |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | public function getIdentityName() |
||
47 | { |
||
48 | $template = '%s\\%s'; |
||
49 | $assembleContent = sprintf( |
||
50 | $template, |
||
51 | $this->getNamespaceName(), |
||
52 | $this->getName() |
||
53 | ); |
||
54 | |||
55 | return $assembleContent; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function getName() |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getNamespaceName() |
||
73 | |||
74 | /** |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function isTrait() |
||
81 | |||
82 | /** |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function isClass() |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function getLineRange() |
||
94 | { |
||
95 | $startLine = $this->reflection->getStartLine(); |
||
96 | $endLine = $this->reflection->getEndLine(); |
||
97 | |||
98 | return new LineRange($startLine, $endLine); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @return ReflectionCollection |
||
103 | */ |
||
104 | public function getMethods() |
||
105 | { |
||
106 | $className = $this->reflection->name; |
||
107 | $selector = MethodSelector::fromClassName($className); |
||
108 | |||
109 | $result = $selector->excludeNative() |
||
110 | ->excludeInherited() |
||
111 | ->excludeTraitMethods() |
||
112 | ->toCollection(); |
||
113 | |||
114 | return $result; |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function convertToResult(LineResultSelectable $selector) |
||
121 | { |
||
122 | if ($this->isClass()) { |
||
123 | $result = new ClassResult($this, $selector); |
||
124 | } else { |
||
125 | $result = new TraitResult($this, $selector); |
||
126 | } |
||
127 | |||
128 | return $result; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @return string |
||
133 | */ |
||
134 | public function __toString() |
||
138 | |||
139 | } |
||
140 |