| Total Complexity | 6 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class QueryShortcut implements ShortcutInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @throws \Yansongda\Pay\Exception\InvalidParamsException |
||
| 17 | */ |
||
| 18 | public function getPlugins(array $params): array |
||
| 19 | { |
||
| 20 | $typeMethod = ($params['_type'] ?? 'default').'Plugins'; |
||
| 21 | |||
| 22 | if (isset($params['combine_out_trade_no'])) { |
||
| 23 | return $this->combinePlugins(); |
||
|
|
|||
| 24 | } |
||
| 25 | |||
| 26 | if (method_exists($this, $typeMethod)) { |
||
| 27 | return $this->{$typeMethod}(); |
||
| 28 | } |
||
| 29 | |||
| 30 | throw new InvalidParamsException(Exception::SHORTCUT_MULTI_TYPE_ERROR, "Query type [$typeMethod] not supported"); |
||
| 31 | } |
||
| 32 | |||
| 33 | protected function defaultPlugins(): array |
||
| 37 | ]; |
||
| 38 | } |
||
| 39 | |||
| 40 | protected function refundPlugins(): array |
||
| 44 | ]; |
||
| 45 | } |
||
| 46 | |||
| 47 | protected function combinePlugins(): array |
||
| 54 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: