|
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
|
390 |
|
public function __construct(\ReflectionClass $rfc) |
|
28
|
|
|
{ |
|
29
|
390 |
|
$this->rfc = $rfc; |
|
30
|
390 |
|
} |
|
31
|
|
|
|
|
32
|
389 |
|
public static function factory($name) |
|
33
|
|
|
{ |
|
34
|
389 |
|
return new self(new \ReflectionClass($name)); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
380 |
|
public function getName() |
|
38
|
|
|
{ |
|
39
|
380 |
|
return $this->rfc->getName(); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function isAbstract() |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->rfc->isAbstract(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
369 |
|
public function isFinal() |
|
48
|
|
|
{ |
|
49
|
369 |
|
return $this->rfc->isFinal(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
383 |
|
public function getMethods() |
|
53
|
|
|
{ |
|
54
|
|
|
return array_map(function ($method) { |
|
55
|
132 |
|
return new Method($method); |
|
56
|
383 |
|
}, $this->rfc->getMethods()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
24 |
|
public function getInterfaces() |
|
60
|
|
|
{ |
|
61
|
24 |
|
$class = __CLASS__; |
|
62
|
24 |
|
return array_map(function ($interface) use ($class) { |
|
63
|
9 |
|
return new $class($interface); |
|
64
|
24 |
|
}, $this->rfc->getInterfaces()); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
15 |
|
public function __toString() |
|
68
|
|
|
{ |
|
69
|
15 |
|
return $this->getName(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getNamespaceName() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->rfc->getNamespaceName(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function inNamespace() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->rfc->inNamespace(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getShortName() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->rfc->getShortName(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
350 |
|
public function implementsInterface($interface) |
|
88
|
|
|
{ |
|
89
|
350 |
|
return $this->rfc->implementsInterface($interface); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
361 |
|
public function hasInternalAncestor() |
|
93
|
|
|
{ |
|
94
|
361 |
|
if ($this->rfc->isInternal()) { |
|
95
|
41 |
|
return true; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
323 |
|
$child = $this->rfc; |
|
99
|
323 |
|
while ($parent = $child->getParentClass()) { |
|
100
|
4 |
|
if ($parent->isInternal()) { |
|
101
|
2 |
|
return true; |
|
102
|
|
|
} |
|
103
|
3 |
|
$child = $parent; |
|
104
|
3 |
|
} |
|
105
|
|
|
|
|
106
|
322 |
|
return false; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|