| Conditions | 15 | 
| Paths | 2 | 
| Total Lines | 45 | 
| Code Lines | 30 | 
| 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  | 
            ||
| 83 | private function extractData(string $fileName): array  | 
            ||
| 84 |     { | 
            ||
| 85 | $stubContent = null;  | 
            ||
| 86 | $manifestContent = null;  | 
            ||
| 87 | $manifestLength = null;  | 
            ||
| 88 | |||
| 89 | $resource = fopen($fileName, 'r');  | 
            ||
| 90 |         while (!feof($resource)) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 91 | $line = fgets($resource);  | 
            ||
| 92 | // stop reading file when manifest can be extracted  | 
            ||
| 93 |             if ($manifestLength !== null && $manifestContent !== null && strlen($manifestContent) >= $manifestLength) { | 
            ||
| 94 | break;  | 
            ||
| 95 | }  | 
            ||
| 96 | |||
| 97 | $stubPosition = strpos($line, '<?php');  | 
            ||
| 98 | $manifestPosition = strpos($line, '__HALT_COMPILER()');  | 
            ||
| 99 | |||
| 100 | // line contains both, start of (empty) stub and start of manifest  | 
            ||
| 101 | if ($stubContent === null && $stubPosition !== false  | 
            ||
| 102 |                 && $manifestContent === null && $manifestPosition !== false) { | 
            ||
| 103 | $stubContent = substr($line, $stubPosition, $manifestPosition - $stubPosition - 1);  | 
            ||
| 104 |                 $manifestContent = preg_replace('#^.*__HALT_COMPILER\(\)[^>]*\?>(\r|\n)*#', '', $line); | 
            ||
| 105 | $manifestLength = $this->resolveManifestLength($manifestContent);  | 
            ||
| 106 | // line contains start of stub  | 
            ||
| 107 |             } elseif ($stubContent === null && $stubPosition !== false) { | 
            ||
| 108 | $stubContent = substr($line, $stubPosition);  | 
            ||
| 109 | // line contains start of manifest  | 
            ||
| 110 |             } elseif ($manifestContent === null && $manifestPosition !== false) { | 
            ||
| 111 |                 $manifestContent = preg_replace('#^.*__HALT_COMPILER\(\)[^>]*\?>(\r|\n)*#', '', $line); | 
            ||
| 112 | $manifestLength = $this->resolveManifestLength($manifestContent);  | 
            ||
| 113 | // manifest has been started (thus is cannot be stub anymore), add content  | 
            ||
| 114 |             } elseif ($manifestContent !== null) { | 
            ||
| 115 | $manifestContent .= $line;  | 
            ||
| 116 | $manifestLength = $this->resolveManifestLength($manifestContent);  | 
            ||
| 117 | // stub has been started (thus cannot be manifest here, yet), add content  | 
            ||
| 118 |             } elseif ($stubContent !== null) { | 
            ||
| 119 | $stubContent .= $line;  | 
            ||
| 120 | }  | 
            ||
| 121 | }  | 
            ||
| 122 | fclose($resource);  | 
            ||
| 123 | |||
| 124 | return [  | 
            ||
| 125 | 'stubContent' => $stubContent,  | 
            ||
| 126 | 'manifestContent' => $manifestContent,  | 
            ||
| 127 | 'manifestLength' => $manifestLength,  | 
            ||
| 128 | ];  | 
            ||
| 217 |