1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Mockery |
4
|
|
|
* |
5
|
|
|
* LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the new BSD license that is bundled |
8
|
|
|
* with this package in the file LICENSE.txt. |
9
|
|
|
* It is also available through the world-wide-web at this URL: |
10
|
|
|
* http://github.com/padraic/mockery/blob/master/LICENSE |
11
|
|
|
* If you did not receive a copy of the license and are unable to |
12
|
|
|
* obtain it through the world-wide-web, please send an email |
13
|
|
|
* to [email protected] so we can send you a copy immediately. |
14
|
|
|
* |
15
|
|
|
* @category Mockery |
16
|
|
|
* @package Mockery |
17
|
|
|
* @copyright Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com) |
18
|
|
|
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Mockery\Generator; |
22
|
|
|
|
23
|
|
|
class DefinedTargetClass implements TargetClassInterface |
24
|
|
|
{ |
25
|
|
|
private $rfc; |
26
|
|
|
|
27
|
424 |
|
public function __construct(\ReflectionClass $rfc) |
28
|
|
|
{ |
29
|
424 |
|
$this->rfc = $rfc; |
30
|
424 |
|
} |
31
|
|
|
|
32
|
423 |
|
public static function factory($name) |
33
|
|
|
{ |
34
|
423 |
|
return new self(new \ReflectionClass($name)); |
35
|
|
|
} |
36
|
|
|
|
37
|
403 |
|
public function getName() |
38
|
|
|
{ |
39
|
403 |
|
return $this->rfc->getName(); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function isAbstract() |
43
|
|
|
{ |
44
|
|
|
return $this->rfc->isAbstract(); |
45
|
|
|
} |
46
|
|
|
|
47
|
395 |
|
public function isFinal() |
48
|
|
|
{ |
49
|
395 |
|
return $this->rfc->isFinal(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function isTrait() |
53
|
|
|
{ |
54
|
|
|
return $this->rfc->isTrait(); |
55
|
|
|
} |
56
|
|
|
|
57
|
417 |
|
public function getMethods() |
58
|
|
|
{ |
59
|
|
|
return array_map(function ($method) { |
60
|
165 |
|
return new Method($method); |
61
|
417 |
|
}, $this->rfc->getMethods()); |
62
|
|
|
} |
63
|
|
|
|
64
|
24 |
|
public function getInterfaces() |
65
|
|
|
{ |
66
|
24 |
|
$class = __CLASS__; |
67
|
24 |
|
return array_map(function ($interface) use ($class) { |
68
|
9 |
|
return new $class($interface); |
69
|
24 |
|
}, $this->rfc->getInterfaces()); |
70
|
|
|
} |
71
|
|
|
|
72
|
14 |
|
public function __toString() |
73
|
|
|
{ |
74
|
14 |
|
return $this->getName(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getNamespaceName() |
78
|
|
|
{ |
79
|
|
|
return $this->rfc->getNamespaceName(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function inNamespace() |
83
|
|
|
{ |
84
|
|
|
return $this->rfc->inNamespace(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getShortName() |
88
|
|
|
{ |
89
|
|
|
return $this->rfc->getShortName(); |
90
|
|
|
} |
91
|
|
|
|
92
|
376 |
|
public function implementsInterface($interface) |
93
|
|
|
{ |
94
|
376 |
|
return $this->rfc->implementsInterface($interface); |
95
|
|
|
} |
96
|
|
|
|
97
|
387 |
|
public function hasInternalAncestor() |
98
|
|
|
{ |
99
|
387 |
|
if ($this->rfc->isInternal()) { |
100
|
38 |
|
return true; |
101
|
|
|
} |
102
|
|
|
|
103
|
352 |
|
$child = $this->rfc; |
104
|
352 |
|
while ($parent = $child->getParentClass()) { |
105
|
16 |
|
if ($parent->isInternal()) { |
106
|
2 |
|
return true; |
107
|
|
|
} |
108
|
15 |
|
$child = $parent; |
109
|
|
|
} |
110
|
|
|
|
111
|
351 |
|
return false; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|