| Conditions | 10 |
| Paths | 24 |
| Total Lines | 53 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 34 |
| CRAP Score | 10.0023 |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 16 | 57 | { |
|
| 17 | $arrMedia = array(); |
||
| 18 | 57 | for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) { |
|
| 19 | 57 | $shape = $this->getDrawingHashTable()->getByIndex($i);gi |
|
| 20 | 28 | if (!($shape instanceof Drawing\AbstractDrawingAdapter)) { |
|
|
|
|||
| 21 | 28 | continue; |
|
| 22 | 7 | } |
|
| 23 | 7 | if (in_array($shape->getIndexedFilename(), $arrMedia)) { |
|
| 24 | continue; |
||
| 25 | 7 | } |
|
| 26 | $arrMedia[] = $shape->getIndexedFilename(); |
||
| 27 | 7 | $this->getZip()->addFromString('Pictures/' . $shape->getIndexedFilename(), $shape->getContents()); |
|
| 28 | 1 | } |
|
| 29 | 1 | ||
| 30 | foreach ($this->getPresentation()->getAllSlides() as $keySlide => $oSlide) { |
||
| 31 | 1 | // Add background image slide |
|
| 32 | 1 | $oBkgImage = $oSlide->getBackground(); |
|
| 33 | 1 | if ($oBkgImage instanceof Image) { |
|
| 34 | 1 | $this->getZip()->addFromString('Pictures/'.$oBkgImage->getIndexedFilename($keySlide), file_get_contents($oBkgImage->getPath())); |
|
| 35 | 1 | } |
|
| 36 | 7 | } |
|
| 37 | 1 | ||
| 38 | 1 | return $this->getZip(); |
|
| 39 | 1 | } |
|
| 40 | } |
||
| 41 |