| Conditions | 25 |
| Paths | 25 |
| Total Lines | 48 |
| Code Lines | 44 |
| 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 |
||
| 80 | protected function mapSubObjects(string $key, array $data): Types |
||
| 81 | { |
||
| 82 | switch ($key) { |
||
| 83 | case 'from': |
||
| 84 | case 'forward_from': |
||
| 85 | case 'new_chat_member': |
||
| 86 | case 'left_chat_member': |
||
| 87 | return new User($data, $this->logger); |
||
| 88 | case 'new_chat_members': |
||
| 89 | return new UserArray($data, $this->logger); |
||
| 90 | case 'photo': |
||
| 91 | case 'new_chat_photo': |
||
| 92 | return new PhotoSizeArray($data, $this->logger); |
||
| 93 | case 'chat': |
||
| 94 | case 'forward_from_chat': |
||
| 95 | return new Chat($data, $this->logger); |
||
| 96 | case 'reply_to_message': |
||
| 97 | case 'pinned_message': |
||
| 98 | return new Message($data, $this->logger); |
||
| 99 | case 'entities': |
||
| 100 | return new MessageEntityArray($data, $this->logger); |
||
| 101 | case 'audio': |
||
| 102 | return new Audio($data, $this->logger); |
||
| 103 | case 'document': |
||
| 104 | return new Document($data, $this->logger); |
||
| 105 | case 'game': |
||
| 106 | return new Game($data, $this->logger); |
||
| 107 | case 'sticker': |
||
| 108 | return new Sticker($data, $this->logger); |
||
| 109 | case 'video': |
||
| 110 | return new Video($data, $this->logger); |
||
| 111 | case 'voice': |
||
| 112 | return new Voice($data, $this->logger); |
||
| 113 | case 'video_note': |
||
| 114 | return new VideoNote($data, $this->logger); |
||
| 115 | case 'contact': |
||
| 116 | return new Contact($data, $this->logger); |
||
| 117 | case 'location': |
||
| 118 | return new Location($data, $this->logger); |
||
| 119 | case 'venue': |
||
| 120 | return new Venue($data, $this->logger); |
||
| 121 | case 'invoice': |
||
| 122 | return new Invoice($data, $this->logger); |
||
| 123 | case 'successful_payment': |
||
| 124 | return new SuccessfulPayment($data, $this->logger); |
||
| 125 | } |
||
| 126 | // Return always null if none of the objects above matches |
||
| 127 | return parent::mapSubObjects($key, $data); |
||
| 128 | } |
||
| 130 |