| Conditions | 14 | 
| Paths | 30 | 
| Total Lines | 63 | 
| Code Lines | 46 | 
| 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 | ||
| 54 | public function start(string $path, array $properties = []) | ||
| 55 |     { | ||
| 56 |         if ($this->sheetWrapper->getObject() === null) { | ||
| 57 | throw new \LogicException(); | ||
| 58 | } | ||
| 59 | |||
| 60 | // create local copy of the asset | ||
| 61 | $tempPath = $this->createTempCopy($path); | ||
| 62 | |||
| 63 | // add to header/footer | ||
| 64 |         if ($this->headerFooterWrapper->getObject()) { | ||
| 65 | $headerFooterAttributes = $this->headerFooterWrapper->getAttributes(); | ||
| 66 | $location = ''; | ||
| 67 | |||
| 68 |             switch (strtolower($this->headerFooterWrapper->getAlignmentAttributes()['type'])) { | ||
| 69 | case 'left': | ||
| 70 | $location .= 'L'; | ||
| 71 | $headerFooterAttributes['value']['left'] .= '&G'; | ||
| 72 | break; | ||
| 73 | case 'center': | ||
| 74 | $location .= 'C'; | ||
| 75 | $headerFooterAttributes['value']['center'] .= '&G'; | ||
| 76 | break; | ||
| 77 | case 'right': | ||
| 78 | $location .= 'R'; | ||
| 79 | $headerFooterAttributes['value']['right'] .= '&G'; | ||
| 80 | break; | ||
| 81 | default: | ||
| 82 |                     throw new \InvalidArgumentException(sprintf('Unknown alignment type "%s"', $this->headerFooterWrapper->getAlignmentAttributes()['type'])); | ||
| 83 | } | ||
| 84 | |||
| 85 |             switch (strtolower($headerFooterAttributes['type'])) { | ||
| 86 | case 'header': | ||
| 87 | case 'oddheader': | ||
| 88 | case 'evenheader': | ||
| 89 | case 'firstheader': | ||
| 90 | $location .= 'H'; | ||
| 91 | break; | ||
| 92 | case 'footer': | ||
| 93 | case 'oddfooter': | ||
| 94 | case 'evenfooter': | ||
| 95 | case 'firstfooter': | ||
| 96 | $location .= 'F'; | ||
| 97 | break; | ||
| 98 | default: | ||
| 99 |                     throw new \InvalidArgumentException(sprintf('Unknown type "%s"', $headerFooterAttributes['type'])); | ||
| 100 | } | ||
| 101 | |||
| 102 | $this->object = new HeaderFooterDrawing(); | ||
| 103 | $this->object->setPath($tempPath); | ||
| 104 | $this->headerFooterWrapper->getObject()->addImage($this->object, $location); | ||
| 105 | $this->headerFooterWrapper->setAttributes($headerFooterAttributes); | ||
| 106 | } | ||
| 107 | |||
| 108 | // add to worksheet | ||
| 109 |         else { | ||
| 110 | $this->object = new Drawing(); | ||
| 111 | $this->object->setWorksheet($this->sheetWrapper->getObject()); | ||
| 112 | $this->object->setPath($tempPath); | ||
| 113 | } | ||
| 114 | |||
| 115 | $this->setProperties($properties, $this->mappings); | ||
| 116 | } | ||
| 117 | |||
| 201 |