| Conditions | 13 |
| Paths | 282 |
| Total Lines | 55 |
| Code Lines | 31 |
| 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 |
||
| 64 | public function title() |
||
| 65 | { |
||
| 66 | if (isset($this->title)) { |
||
| 67 | return $this->title; |
||
| 68 | } |
||
| 69 | |||
| 70 | try { |
||
| 71 | $config = $this->dashboardConfig(); |
||
| 72 | |||
| 73 | if (isset($config['title'])) { |
||
| 74 | $this->title = $this->translator()->translation($config['title']); |
||
| 75 | |||
| 76 | return $this->title; |
||
| 77 | } |
||
| 78 | } catch (Exception $e) { |
||
| 79 | $this->logger->error($e->getMessage()); |
||
| 80 | } |
||
| 81 | |||
| 82 | $obj = $this->obj(); |
||
| 83 | $metadata = $obj->metadata(); |
||
| 84 | $objLabel = null; |
||
| 85 | |||
| 86 | if (!$objLabel && isset($metadata['admin']['forms'])) { |
||
| 87 | $adminMetadata = $metadata['admin']; |
||
| 88 | |||
| 89 | $formIdent = filter_input(INPUT_GET, 'form_ident', FILTER_SANITIZE_STRING); |
||
| 90 | if (!$formIdent) { |
||
| 91 | $formIdent = (isset($adminMetadata['default_form']) ? $adminMetadata['default_form'] : ''); |
||
| 92 | } |
||
| 93 | |||
| 94 | if (isset($adminMetadata['forms'][$formIdent]['label'])) { |
||
| 95 | $objLabel = $this->translator()->translation($adminMetadata['forms'][$formIdent]['label']); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | if (!$objLabel) { |
||
| 100 | $objType = (isset($metadata['labels']['singular_name']) ? |
||
| 101 | $this->translator()->translation($metadata['labels']['singular_name']) : null); |
||
| 102 | |||
| 103 | $objLabel = $this->translator()->translation('Documentation: {{ objType }}'); |
||
| 104 | |||
| 105 | if ($objType) { |
||
| 106 | $objLabel = strtr($objLabel, [ |
||
| 107 | '{{ objType }}' => $objType |
||
| 108 | ]); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | if ($obj->view()) { |
||
| 113 | $this->title = $obj->render((string)$objLabel, $obj); |
||
| 114 | } else { |
||
| 115 | $this->title = (string)$objLabel; |
||
| 116 | } |
||
| 117 | |||
| 118 | return $this->title; |
||
| 119 | } |
||
| 209 |