Conditions | 17 |
Paths | 1362 |
Total Lines | 69 |
Code Lines | 39 |
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 |
||
83 | public function title() |
||
84 | { |
||
85 | if (isset($this->title)) { |
||
86 | return $this->title; |
||
|
|||
87 | } |
||
88 | |||
89 | $translator = $this->translator(); |
||
90 | |||
91 | try { |
||
92 | $config = $this->dashboardConfig(); |
||
93 | |||
94 | if (isset($config['title'])) { |
||
95 | $this->title = $translator->translation($config['title']); |
||
96 | return $this->title; |
||
97 | } |
||
98 | } catch (Exception $e) { |
||
99 | $this->logger->error($e->getMessage()); |
||
100 | } |
||
101 | |||
102 | $model = $this->proto(); |
||
103 | $metadata = $model->metadata(); |
||
104 | $objLabel = null; |
||
105 | |||
106 | if (!$objLabel && isset($metadata['admin']['lists'])) { |
||
107 | $adminMetadata = $metadata['admin']; |
||
108 | |||
109 | $listIdent = filter_input(INPUT_GET, 'collection_ident', FILTER_SANITIZE_STRING); |
||
110 | if (!$listIdent) { |
||
111 | $listIdent = $this->collectionIdent(); |
||
112 | } |
||
113 | |||
114 | if (!$listIdent) { |
||
115 | $listIdent = $this->collectionIdentFallback(); |
||
116 | } |
||
117 | |||
118 | if ($listIdent && $model->view()) { |
||
119 | $listIdent = $model->render($listIdent); |
||
120 | } |
||
121 | |||
122 | if (isset($adminMetadata['lists'][$listIdent]['label'])) { |
||
123 | $objLabel = $translator->translation($adminMetadata['lists'][$listIdent]['label']); |
||
124 | } |
||
125 | } |
||
126 | |||
127 | if (!$objLabel && isset($metadata['labels']['all_items'])) { |
||
128 | $objLabel = $translator->translation($metadata['labels']['all_items']); |
||
129 | } |
||
130 | |||
131 | if (!$objLabel) { |
||
132 | $objType = (isset($metadata['labels']['name']) |
||
133 | ? $translator->translation($metadata['labels']['name']) |
||
134 | : null); |
||
135 | |||
136 | $objLabel = $translator->translation('Collection: {{ objType }}'); |
||
137 | |||
138 | if ($objType) { |
||
139 | $objLabel = strtr($objLabel, [ |
||
140 | '{{ objType }}' => $objType |
||
141 | ]); |
||
142 | } |
||
143 | } |
||
144 | |||
145 | if ($model->view()) { |
||
146 | $this->title = $model->render((string)$objLabel, $model); |
||
147 | } else { |
||
148 | $this->title = (string)$objLabel; |
||
149 | } |
||
150 | |||
151 | return $this->title; |
||
152 | } |
||
271 |