| Conditions | 8 |
| Paths | 14 |
| Total Lines | 55 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 60 | public function handle() |
||
| 61 | { |
||
| 62 | $config = Di::getDefault()->getConfig(); |
||
| 63 | |||
| 64 | if (empty($this->users)) { |
||
| 65 | return false; |
||
| 66 | } |
||
| 67 | |||
| 68 | $userDevicesArray = UserLinkedSources::getMobileUserLinkedSources($this->users->getId()); |
||
| 69 | |||
| 70 | if (empty($userDevicesArray[2]) && empty($userDevicesArray[3])) { |
||
| 71 | return false; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * One signal array params. |
||
| 76 | */ |
||
| 77 | $pushBody = [ |
||
| 78 | 'contents' => [ |
||
| 79 | 'en' => $this->message |
||
| 80 | ], |
||
| 81 | 'data' => $this->params |
||
| 82 | ]; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @todo change to use some constante , ID dont tell you what device it is |
||
| 86 | */ |
||
| 87 | //send push android |
||
| 88 | if (!empty($userDevicesArray[2])) { |
||
| 89 | $pushBody['include_player_ids'][] = $userDevicesArray[2][0]; |
||
| 90 | } |
||
| 91 | |||
| 92 | //ios |
||
| 93 | if (!empty($userDevicesArray[3])) { |
||
| 94 | $pushBody['include_player_ids'][] = $userDevicesArray[3][0]; |
||
| 95 | } |
||
| 96 | |||
| 97 | try { |
||
| 98 | $this->oneSignal( |
||
| 99 | $config->pushNotifications->appId, |
||
| 100 | $config->pushNotifications->authKey, |
||
| 101 | $config->pushNotifications->userAuthKey |
||
| 102 | )->notifications->add( |
||
| 103 | $pushBody |
||
| 104 | ); |
||
| 105 | } catch (Exception $e) { |
||
| 106 | if (Di::getDefault()->has('log')) { |
||
| 107 | Di::getDefault()->get('log')->error( |
||
| 108 | 'Error sending push notification via OneSignal - ' . $e->getMessage(), |
||
| 109 | [$e->getTraceAsString()] |
||
| 110 | ); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | return true; |
||
| 115 | } |
||
| 141 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths