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