Conditions | 7 |
Paths | 20 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 7.1429 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 14 | public function detectFromHttpRequestTrait($modelManager, $callback = null, $httpRequest = null) |
|
23 | { |
||
24 | 14 | $callback = $callback ? $callback : 'completePurchase'; |
|
25 | 14 | if ($httpRequest) { |
|
26 | 13 | $this->setHttpRequest($httpRequest); |
|
27 | } |
||
28 | 14 | if (!method_exists($this, $callback)) { |
|
29 | 1 | return false; |
|
30 | } |
||
31 | /** @var AbstractRequest $request */ |
||
32 | 13 | $request = $this->$callback(['modelManager' => $modelManager]); |
|
33 | 13 | if (!is_object($request)) { |
|
34 | return false; |
||
35 | } |
||
36 | 13 | if (!method_exists($request, 'isValidNotification')) { |
|
37 | throw new \Exception("Request must have a isValidNotification public method"); |
||
38 | } |
||
39 | 13 | if (!$request->isValidNotification()) { |
|
40 | 10 | return false; |
|
41 | } |
||
42 | |||
43 | 13 | return $request; |
|
44 | } |
||
46 |