| Conditions | 18 | 
| Paths | 26 | 
| Total Lines | 84 | 
| Code Lines | 60 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 1 | 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  | 
            ||
| 84 | public function handleData()  | 
            ||
| 85 |     { | 
            ||
| 86 | $firstLine = trim(strtok($this->getData(), "\n"));  | 
            ||
| 87 | $this->changeSetBoundary = substr($firstLine, 40);  | 
            ||
| 88 | |||
| 89 | $prefix = 'HTTP_';  | 
            ||
| 90 |         $matches = explode('--' . $this->changeSetBoundary, $this->getData()); | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 91 | array_shift($matches);  | 
            ||
| 92 | $contentIDinit = -1;  | 
            ||
| 93 |         foreach ($matches as $match) { | 
            ||
| 94 |             if ('--' === trim($match)) { | 
            ||
| 95 | continue;  | 
            ||
| 96 | }  | 
            ||
| 97 | |||
| 98 | $stage = 0;  | 
            ||
| 99 | $gotRequestPathParts = false;  | 
            ||
| 100 | $match = trim($match);  | 
            ||
| 101 |             $lines = explode("\n", $match); | 
            ||
| 102 | |||
| 103 | $requestPathParts = [];  | 
            ||
| 104 | $serverParts = [];  | 
            ||
| 105 | $contentID = $contentIDinit;  | 
            ||
| 106 | $content = '';  | 
            ||
| 107 | |||
| 108 |             foreach ($lines as $line) { | 
            ||
| 109 |                 if ('' == $line) { | 
            ||
| 110 | $stage++;  | 
            ||
| 111 | continue;  | 
            ||
| 112 | }  | 
            ||
| 113 |                 switch ($stage) { | 
            ||
| 114 | case 0:  | 
            ||
| 115 |                         if (strtolower('Content-Type') == strtolower(substr($line, 0, 12)) | 
            ||
| 116 | && 'application/http' != strtolower(substr($line, -16))  | 
            ||
| 117 |                         ) { | 
            ||
| 118 | //TODO: throw an error about incorrect content type for changeSet  | 
            ||
| 119 | }  | 
            ||
| 120 |                         if (strtolower('Content-Transfer-Encoding') == strtolower(substr($line, 0, 25)) | 
            ||
| 121 | && 'binary' != strtolower(substr($line, -6))  | 
            ||
| 122 |                         ) { | 
            ||
| 123 | //TODO: throw an error about unsupported encoding  | 
            ||
| 124 | }  | 
            ||
| 125 | break;  | 
            ||
| 126 | case 1:  | 
            ||
| 127 |                         if (!$gotRequestPathParts) { | 
            ||
| 128 |                             $requestPathParts = explode(' ', $line); | 
            ||
| 129 | $gotRequestPathParts = true;  | 
            ||
| 130 | continue;  | 
            ||
| 131 | }  | 
            ||
| 132 |                         $headerSides = explode(':', $line); | 
            ||
| 133 |                         if (count($headerSides) != 2) { | 
            ||
| 134 |                             throw new \Exception('Malformed header line: '.$line); | 
            ||
| 135 | }  | 
            ||
| 136 |                         if (strtolower(trim($headerSides[0])) == strtolower('Content-ID')) { | 
            ||
| 137 | $contentID = trim($headerSides[1]);  | 
            ||
| 138 | continue;  | 
            ||
| 139 | }  | 
            ||
| 140 | |||
| 141 | $name = trim($headerSides[0]);  | 
            ||
| 142 | $name = strtr(strtoupper($name), '-', '_');  | 
            ||
| 143 | $value = trim($headerSides[1]);  | 
            ||
| 144 |                         if (!starts_with($name, $prefix) && $name != 'CONTENT_TYPE') { | 
            ||
| 145 | $name = $prefix . $name;  | 
            ||
| 146 | }  | 
            ||
| 147 | $serverParts[$name] = $value;  | 
            ||
| 148 | |||
| 149 | break;  | 
            ||
| 150 | case 2:  | 
            ||
| 151 | $content .= $line;  | 
            ||
| 152 | break;  | 
            ||
| 153 | default:  | 
            ||
| 154 |                         throw new \Exception('how did we end up with more than 3 stages??'); | 
            ||
| 155 | }  | 
            ||
| 156 | }  | 
            ||
| 157 | |||
| 158 |             if ($contentIDinit == $contentID) { | 
            ||
| 159 | $contentIDinit--;  | 
            ||
| 160 | }  | 
            ||
| 161 | $this->rawRequests[$contentID] = (object)[  | 
            ||
| 162 | 'RequestVerb' => $requestPathParts[0],  | 
            ||
| 163 | 'RequestURL' => $requestPathParts[1],  | 
            ||
| 164 | 'ServerParams' => $serverParts,  | 
            ||
| 165 | 'Content' => $content,  | 
            ||
| 166 | 'Request' => null,  | 
            ||
| 167 | 'Response' => null  | 
            ||
| 168 | ];  | 
            ||
| 203 |