Conditions | 10 |
Paths | 16 |
Total Lines | 27 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
29 | public function __construct(Request $request) |
||
30 | { |
||
31 | $payload = $request->request->all(); |
||
32 | foreach ($payload as $item) { |
||
33 | $msys = $item['msys']; |
||
34 | if (isset($msys['message_event'])) { |
||
35 | $event = $msys['message_event']; |
||
36 | } elseif (isset($msys['unsubscribe_event'])) { |
||
37 | $event = $msys['unsubscribe_event']; |
||
38 | } else { |
||
39 | continue; |
||
40 | } |
||
41 | |||
42 | if (isset($event['rcpt_type']) && 'to' !== $event['rcpt_type']) { |
||
43 | // Ignore cc/bcc |
||
44 | |||
45 | continue; |
||
46 | } |
||
47 | |||
48 | $bounceClass = isset($event['bounce_class']) ? (int) $event['bounce_class'] : null; |
||
49 | if (empty($event['type']) || !CallbackEnum::shouldBeEventProcessed($event['type'], $bounceClass)) { |
||
|
|||
50 | continue; |
||
51 | } |
||
52 | |||
53 | try { |
||
54 | $this->items[] = new ResponseItem($event); |
||
55 | } catch (ResponseItemException $e) { |
||
56 | } |
||
116 |