| Conditions | 13 |
| Paths | 17 |
| Total Lines | 38 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 46 | public function resolveUri($obj, ?string $fieldName = null, ?string $className = null): ?string |
||
| 47 | { |
||
| 48 | |||
| 49 | [$mapping, $name] = $this->getFilename($obj, $fieldName, $className); |
||
| 50 | |||
| 51 | if (empty($name)) { |
||
| 52 | return null; |
||
| 53 | } |
||
| 54 | |||
| 55 | $uploadDir = $this->convertWindowsDirectorySeparator($mapping->getUploadDir($obj)); |
||
| 56 | $uploadDir = empty($uploadDir) ? '' : $uploadDir.'/'; |
||
| 57 | |||
| 58 | $tmp = \sprintf('%s/%s', $mapping->getUriPrefix(), $uploadDir.$name); |
||
| 59 | |||
| 60 | if (null !== $tmp && $obj instanceof PaymentOrder) { |
||
| 61 | if ('printed_form' === $fieldName || 'printed_form_file' === $fieldName) { |
||
| 62 | return $this->router->generate('file_payment_order_form', [ |
||
| 63 | 'id' => $obj->getId(), |
||
| 64 | ]); |
||
| 65 | } |
||
| 66 | |||
| 67 | if ('references' === $fieldName || 'references_file' === $fieldName) { |
||
| 68 | return $this->router->generate('file_payment_order_references', [ |
||
| 69 | 'id' => $obj->getId(), |
||
| 70 | ]); |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | if (null !== $tmp && $obj instanceof SEPAExport) |
||
| 75 | { |
||
| 76 | if ('xml' === $fieldName || 'xml_file' === $fieldName) { |
||
| 77 | return $this->router->generate('file_sepa_export_xml', [ |
||
| 78 | 'id' => $obj->getId(), |
||
| 79 | ]); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 83 | return $tmp; |
||
| 84 | } |
||
| 116 |