| Conditions | 11 | 
| Paths | 58 | 
| Total Lines | 32 | 
| Code Lines | 22 | 
| 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  | 
            ||
| 53 | public function getPayloadEntity()  | 
            ||
| 54 |     { | 
            ||
| 55 |         if (!$this->rawPayload) { | 
            ||
| 56 | $this->rawPayload = $this->getRequestPayload();  | 
            ||
| 57 | }  | 
            ||
| 58 | |||
| 59 |         if (!$this->rawPayload) { | 
            ||
| 60 |             throw new \UnexpectedValueException('Got empty action request payload.', 40); | 
            ||
| 61 | }  | 
            ||
| 62 | |||
| 63 |         if (is_string($this->rawPayload)) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 64 | $payload = $this->unserializePayload($this->rawPayload);  | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 |         if (isset($payload['payload'])) { | 
            ||
| 68 | $payload = $payload['payload'];  | 
            ||
| 69 | }  | 
            ||
| 70 | |||
| 71 |         switch ($this->action) { | 
            ||
| 72 | case Action::ACTION_CREATE_PRODUCT:  | 
            ||
| 73 | case Action::ACTION_UPDATE_PRODUCT:  | 
            ||
| 74 | return new ProductRequestEntity($payload);  | 
            ||
| 75 | case Action::ACTION_REMOVE_PRODUCT:  | 
            ||
| 76 | return new ProductRemovedRequestEntity($payload);  | 
            ||
| 77 | case Action::ACTION_ADD_INVENTORY:  | 
            ||
| 78 | case Action::ACTION_SET_INVENTORY:  | 
            ||
| 79 | case Action::ACTION_SUBTRACT_INVENTORY:  | 
            ||
| 80 | return new InventoryChangedEntity($payload);  | 
            ||
| 81 | default:  | 
            ||
| 82 | throw new \RuntimeException(  | 
            ||
| 83 |                     sprintf('Payload entity not found for action %s', $this->action), | 
            ||
| 84 | 41  | 
            ||
| 85 | );  | 
            ||
| 114 |