| Conditions | 14 |
| Paths | 300 |
| Total Lines | 41 |
| Code Lines | 24 |
| 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 |
||
| 128 | protected function fetch() { |
||
| 129 | |||
| 130 | $content = imap_fetchbody($this->oMessage->getClient()->getConnection(), $this->oMessage->getUid(), $this->part_number, $this->oMessage->getFetchOptions()); |
||
|
|
|||
| 131 | |||
| 132 | $this->content_type = $this->type.'/'.strtolower($this->structure->subtype); |
||
| 133 | $this->content = $this->oMessage->decodeString($content, $this->structure->encoding); |
||
| 134 | |||
| 135 | if (property_exists($this->structure, 'id')) { |
||
| 136 | $this->id = str_replace(['<', '>'], '', $this->structure->id); |
||
| 137 | } |
||
| 138 | |||
| 139 | if (property_exists($this->structure, 'dparameters')) { |
||
| 140 | foreach ($this->structure->dparameters as $parameter) { |
||
| 141 | if (strtolower($parameter->attribute) == "filename") { |
||
| 142 | $this->name = $parameter->value; |
||
| 143 | $this->disposition = property_exists($this->structure, 'disposition') ? $this->structure->disposition : null; |
||
| 144 | break; |
||
| 145 | } |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | if (self::TYPE_MESSAGE == $this->structure->type) { |
||
| 150 | if ($this->structure->ifdescription) { |
||
| 151 | $this->name = $this->structure->description; |
||
| 152 | } else { |
||
| 153 | $this->name = $this->structure->subtype; |
||
| 154 | } |
||
| 155 | } |
||
| 156 | |||
| 157 | if (!$this->name && property_exists($this->structure, 'parameters')) { |
||
| 158 | foreach ($this->structure->parameters as $parameter) { |
||
| 159 | if (strtolower($parameter->attribute) == "name") { |
||
| 160 | $this->name = $parameter->value; |
||
| 161 | $this->disposition = property_exists($this->structure, 'disposition') ? $this->structure->disposition : null; |
||
| 162 | break; |
||
| 163 | } |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | if ($this->type == 'image') { |
||
| 168 | $this->img_src = 'data:'.$this->content_type.';base64,'.base64_encode($this->content); |
||
| 169 | } |
||
| 251 | } |