| Conditions | 17 | 
| Paths | 13 | 
| Total Lines | 47 | 
| Code Lines | 35 | 
| 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 | ||
| 100 | public function getPHPoole(array $options=[]) | ||
| 101 |     { | ||
| 102 |         $messageCallback = function ($code, $message = '', $itemsCount = 0, $itemsMax = 0, $verbose = true) { | ||
| 103 |             switch (true) { | ||
| 104 | case $code == 'CREATE' | ||
| 105 | || $code == 'CONVERT' | ||
| 106 | || $code == 'GENERATE' | ||
| 107 | || $code == 'RENDER' | ||
| 108 | || $code == 'COPY': | ||
| 109 | $this->wlAnnonce($message); | ||
| 110 | break; | ||
| 111 | case $code == 'CREATE_PROGRESS' | ||
| 112 | || $code == 'CONVERT_PROGRESS' | ||
| 113 | || $code == 'GENERATE_PROGRESS' | ||
| 114 | || $code == 'RENDER_PROGRESS' | ||
| 115 | || $code == 'COPY_PROGRESS': | ||
| 116 |                     if ($itemsCount > 0 && $verbose !== false) { | ||
| 117 |                         $this->wlDone(sprintf("\r  (%u/%u) %s", $itemsCount, $itemsMax, $message)); | ||
| 118 | break; | ||
| 119 | } | ||
| 120 |                     $this->wlDone("  $message"); | ||
| 121 | break; | ||
| 122 | } | ||
| 123 | }; | ||
| 124 | |||
| 125 |         if (!$this->phpoole instanceof PHPoole) { | ||
| 126 |             if (!file_exists($this->getPath().'/'.self::CONFIG_FILE)) { | ||
| 127 |                 $this->wlError('Config file (phpoole.yml) not found!'); | ||
| 128 | exit(2); | ||
| 129 | } | ||
| 130 | |||
| 131 |             try { | ||
| 132 | $optionsFile = (new Yaml())->parse(file_get_contents($this->getPath().'/'.self::CONFIG_FILE)); | ||
| 133 |                 if (is_array($options)) { | ||
| 134 | $options = array_replace_recursive($optionsFile, $options); | ||
| 135 | } | ||
| 136 | $this->phpoole = new PHPoole($options, $messageCallback); | ||
| 137 | $this->phpoole->setSourceDir($this->getPath()); | ||
| 138 | $this->phpoole->setDestinationDir($this->getPath()); | ||
| 139 |             } catch (\Exception $e) { | ||
| 140 | $this->wlError($e->getMessage()); | ||
| 141 | exit(2); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | return $this->phpoole; | ||
| 146 | } | ||
| 147 | |||
| 180 | 
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@returndoc comment to communicate to implementors of these methods what they are expected to return.