1: <?php
2:
3: namespace Mockery\Generator;
4:
5: class DefinedTargetClass
6: {
7: private $rfc;
8:
9: public function __construct(\ReflectionClass $rfc)
10: {
11: $this->rfc = $rfc;
12: }
13:
14: public static function factory($name)
15: {
16: return new self(new \ReflectionClass($name));
17: }
18:
19: public function getName()
20: {
21: return $this->rfc->getName();
22: }
23:
24: public function isAbstract()
25: {
26: return $this->rfc->isAbstract();
27: }
28:
29: public function isFinal()
30: {
31: return $this->rfc->isFinal();
32: }
33:
34: public function getMethods()
35: {
36: return array_map(function ($method) {
37: return new Method($method);
38: }, $this->rfc->getMethods());
39: }
40:
41: public function getInterfaces()
42: {
43: $class = __CLASS__;
44: return array_map(function ($interface) use ($class) {
45: return new $class($interface);
46: }, $this->rfc->getInterfaces());
47: }
48:
49: public function __toString()
50: {
51: return $this->getName();
52: }
53:
54: public function getNamespaceName()
55: {
56: return $this->rfc->getNamespaceName();
57: }
58:
59: public function inNamespace()
60: {
61: return $this->rfc->inNamespace();
62: }
63:
64: public function getShortName()
65: {
66: return $this->rfc->getShortName();
67: }
68:
69: public function implementsInterface($interface)
70: {
71: return $this->rfc->implementsInterface($interface);
72: }
73:
74: public function hasInternalAncestor()
75: {
76: if ($this->rfc->isInternal()) {
77: return true;
78: }
79:
80: $child = $this->rfc;
81: while ($parent = $child->getParentClass()) {
82: if ($parent->isInternal()) {
83: return true;
84: }
85: $child = $parent;
86: }
87:
88: return false;
89: }
90: }
91: