1 | <?php |
||
19 | abstract class AbstractMockingStrategy implements MockingStrategyInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $mockType; |
||
25 | |||
26 | /** |
||
27 | * @param string $dependencyClassName |
||
28 | * @param string $dependencyPackageName |
||
29 | * |
||
30 | * @throws MissingDependencyException |
||
31 | */ |
||
32 | 10 | final protected static function checkDependencies(string $dependencyClassName, string $dependencyPackageName) |
|
44 | |||
45 | /** |
||
46 | * @param string $fqcn |
||
47 | * @return object |
||
48 | * |
||
49 | * @throws MockNotCreatedException |
||
50 | */ |
||
51 | 85 | public function build(string $fqcn) |
|
65 | |||
66 | /** |
||
67 | * @param object $mock |
||
68 | * @param StubInterface[] $stubs |
||
69 | * @return void |
||
70 | * |
||
71 | * @throws InvalidArgumentException |
||
72 | * @throws NotImplementedException |
||
73 | */ |
||
74 | 76 | public function decorate($mock, array $stubs) |
|
90 | |||
91 | /** |
||
92 | * @param object $mock |
||
93 | * @return object |
||
94 | * |
||
95 | * @throws NotImplementedException |
||
96 | * @throws InvalidArgumentException |
||
97 | */ |
||
98 | 71 | public function get($mock) |
|
104 | |||
105 | /** |
||
106 | * @param object $mock |
||
107 | * @param string $methodName |
||
108 | * @return mixed |
||
109 | * |
||
110 | * @throws NotImplementedException |
||
111 | */ |
||
112 | 3 | public function call($mock, string $methodName) |
|
118 | |||
119 | /** |
||
120 | * @return string |
||
121 | * |
||
122 | * @throws NotImplementedException |
||
123 | */ |
||
124 | 21 | public function getMockType(): string |
|
130 | |||
131 | /** |
||
132 | * @param string $fqcn |
||
133 | */ |
||
134 | 11 | final protected function setMockType(string $fqcn) |
|
138 | |||
139 | /** |
||
140 | * @param object $mock |
||
141 | * |
||
142 | * @throws NotImplementedException |
||
143 | * @throws InvalidArgumentException |
||
144 | */ |
||
145 | 85 | final protected function checkMockType($mock) |
|
159 | |||
160 | /** |
||
161 | * @return void |
||
162 | * |
||
163 | * @throws NotImplementedException |
||
164 | */ |
||
165 | 86 | private function verifyMockType() |
|
171 | |||
172 | /** |
||
173 | * @param string $fqcn |
||
174 | * @return object |
||
175 | */ |
||
176 | abstract protected function doBuild(string $fqcn); |
||
177 | |||
178 | /** |
||
179 | * @param object $mock |
||
180 | * @param PropertyStub $stub |
||
181 | * @return void |
||
182 | */ |
||
183 | 76 | protected function doDecorateWithProperty($mock, PropertyStub $stub) |
|
187 | |||
188 | /** |
||
189 | * @param object $mock |
||
190 | * @param MethodStub $stub |
||
191 | * @return void |
||
192 | */ |
||
193 | abstract protected function doDecorateWithMethod($mock, MethodStub $stub); |
||
194 | |||
195 | /** |
||
196 | * @param object $mock |
||
197 | * @return object |
||
198 | */ |
||
199 | abstract protected function doGet($mock); |
||
200 | |||
201 | /** |
||
202 | * @param object $mock |
||
203 | * @param string $methodName |
||
204 | * @return mixed |
||
205 | * |
||
206 | * @throws \Error |
||
207 | */ |
||
208 | 1 | protected function doCall($mock, string $methodName) |
|
218 | } |
||
219 |