| Conditions | 29 |
| Paths | 18 |
| Total Lines | 50 |
| Code Lines | 38 |
| 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 |
||
| 45 | public static function createOfficialAccountEvent(array $message): Event |
||
| 46 | { |
||
| 47 | $type = $message['MsgType'] ?? ''; |
||
| 48 | $event = $message['Event'] ?? ''; |
||
| 49 | $eventKey = $message['EventKey'] ?? ''; |
||
| 50 | |||
| 51 | /** 用户发送的消息 */ |
||
| 52 | if ('text' === $type) { |
||
| 53 | return static::$app->make(UserMessageText::class, ['message' => $message]); |
||
| 54 | } elseif ('image' === $type) { |
||
| 55 | return static::$app->make(UserMessageImage::class, ['message' => $message]); |
||
| 56 | } elseif ('voice' === $type) { |
||
| 57 | return static::$app->make(UserMessageVoice::class, ['message' => $message]); |
||
| 58 | } elseif ('video' === $type) { |
||
| 59 | return static::$app->make(UserMessageVideo::class, ['message' => $message]); |
||
| 60 | } elseif ('shortvideo' === $type) { |
||
| 61 | return static::$app->make(UserMessageShortVideo::class, ['message' => $message]); |
||
| 62 | } elseif ('location' === $type) { |
||
| 63 | return static::$app->make(UserMessageLocation::class, ['message' => $message]); |
||
| 64 | } elseif ('link' === $type) { |
||
| 65 | return static::$app->make(UserMessageLink::class, ['message' => $message]); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** 用户行为事件 */ |
||
| 69 | if ('event' === $type && $event === 'subscribe' && Str::startsWith($eventKey, 'qrscene_')) { |
||
| 70 | return static::$app->make(UserEventSubscribeWithScan::class, ['message' => $message]); |
||
| 71 | } elseif ('event' === $type && $event === 'subscribe') { |
||
| 72 | return static::$app->make(UserEventSubscribe::class, ['message' => $message]); |
||
| 73 | } elseif ('event' === $type && $event === 'unsubscribe') { |
||
| 74 | return static::$app->make(UserEventUnsubscribe::class, ['message' => $message]); |
||
| 75 | } elseif ('event' === $type && $event === 'SCAN') { |
||
| 76 | return static::$app->make(UserEventScan::class, ['message' => $message]); |
||
| 77 | } elseif ('event' === $type && $event === 'unsubscribe') { |
||
| 78 | return static::$app->make(UserEventUnsubscribe::class, ['message' => $message]); |
||
| 79 | } elseif ('event' === $type && $event === 'LOCATION') { |
||
| 80 | return static::$app->make(UserEventLocation::class, ['message' => $message]); |
||
| 81 | } elseif ('event' === $type && $event === 'CLICK') { |
||
| 82 | return static::$app->make(UserEventMenuClickButton::class, ['message' => $message]); |
||
| 83 | } elseif ('event' === $type && $event === 'VIEW') { |
||
| 84 | return static::$app->make(UserEventMenuClickView::class, ['message' => $message]); |
||
| 85 | } elseif ('event' === $type && $event === 'view_miniprogram') { |
||
| 86 | return static::$app->make(UserEventMenuClickMiniProgram::class, ['message' => $message]); |
||
| 87 | } |
||
| 88 | |||
| 89 | /** 模版消息 */ |
||
| 90 | if ('event' === $type && $event === 'TEMPLATESENDJOBFINISH') { |
||
| 91 | return static::$app->make(TemplateMessageEventSendJobFinish::class, ['message' => $message]); |
||
| 92 | } |
||
| 93 | |||
| 94 | return static::$app->make(Event::class, ['message' => $message]); |
||
| 95 | } |
||
| 97 |
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