| Conditions | 16 | 
| Paths | 15 | 
| Total Lines | 50 | 
| Code Lines | 33 | 
| 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  | 
            ||
| 60 | public function incoming(HTTPRequest $req)  | 
            ||
| 61 |     { | 
            ||
| 62 | $generatedSignature = $this->generateSignature($req->postVars());  | 
            ||
| 63 |         $mandrillSignature = $req->getHeader('X-Mandrill-Signature'); | 
            ||
| 64 |         $json = $req->postVar('mandrill_events'); | 
            ||
| 65 | |||
| 66 | // By default, return a valid response  | 
            ||
| 67 | $response = $this->getResponse();  | 
            ||
| 68 | $response->setStatusCode(200);  | 
            ||
| 69 |         $response->setBody(''); | 
            ||
| 70 | |||
| 71 | //make sure the generated signature matches the X-Mandrill-Signature header  | 
            ||
| 72 |         if (self::config()->webhook_auth_enabled && $generatedSignature !== $mandrillSignature) { | 
            ||
| 73 | return $response;  | 
            ||
| 74 | }  | 
            ||
| 75 | |||
| 76 |         if (!$json) { | 
            ||
| 77 | return $response;  | 
            ||
| 78 | }  | 
            ||
| 79 | |||
| 80 | $events = json_decode($json);  | 
            ||
| 81 | |||
| 82 |         foreach ($events as $ev) { | 
            ||
| 83 | $this->handleAnyEvent($ev);  | 
            ||
| 84 | |||
| 85 | $event = $ev->event;  | 
            ||
| 86 |             switch ($event) { | 
            ||
| 87 | // Sync type  | 
            ||
| 88 | case self::EVENT_BLACKLIST:  | 
            ||
| 89 | case self::EVENT_WHITELIST:  | 
            ||
| 90 | $this->handleSyncEvent($ev);  | 
            ||
| 91 | break;  | 
            ||
| 92 | // Inbound type  | 
            ||
| 93 | case self::EVENT_INBOUND:  | 
            ||
| 94 | $this->handleInboundEvent($ev);  | 
            ||
| 95 | break;  | 
            ||
| 96 | // Message type  | 
            ||
| 97 | case self::EVENT_CLICK:  | 
            ||
| 98 | case self::EVENT_HARD_BOUNCE:  | 
            ||
| 99 | case self::EVENT_OPEN:  | 
            ||
| 100 | case self::EVENT_REJECT:  | 
            ||
| 101 | case self::EVENT_SEND:  | 
            ||
| 102 | case self::EVENT_SOFT_BOUNCE:  | 
            ||
| 103 | case self::EVENT_SPAM:  | 
            ||
| 104 | case self::EVENT_UNSUB:  | 
            ||
| 105 | $this->handleMessageEvent($ev);  | 
            ||
| 106 | break;  | 
            ||
| 107 | }  | 
            ||
| 108 | }  | 
            ||
| 109 | return $response;  | 
            ||
| 110 | }  | 
            ||
| 179 |