| Conditions | 22 | 
| Paths | 1011 | 
| Total Lines | 76 | 
| Code Lines | 45 | 
| 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  | 
            ||
| 44 | public function title()  | 
            ||
| 45 |     { | 
            ||
| 46 |         if ($this->title === null) { | 
            ||
| 47 | $title = null;  | 
            ||
| 48 | |||
| 49 | $translator = $this->translator();  | 
            ||
| 50 | |||
| 51 |             try { | 
            ||
| 52 | $config = $this->dashboardConfig();  | 
            ||
| 53 |             } catch (Exception $e) { | 
            ||
| 54 | $this->logger->error($e->getMessage());  | 
            ||
| 55 | $config = [];  | 
            ||
| 56 | }  | 
            ||
| 57 | |||
| 58 |             if (isset($config['title'])) { | 
            ||
| 59 | $title = $translator->translation($config['title']);  | 
            ||
| 60 |             } else { | 
            ||
| 61 | $obj = $this->obj();  | 
            ||
| 62 | $objId = $this->objId();  | 
            ||
| 63 | $objType = $this->objType();  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 64 | $metadata = $obj->metadata();  | 
            ||
| 65 | |||
| 66 |                 if (!$title && isset($metadata['admin']['forms'])) { | 
            ||
| 67 | $adminMetadata = $metadata['admin'];  | 
            ||
| 68 | |||
| 69 | $formIdent = filter_input(INPUT_GET, 'form_ident', FILTER_SANITIZE_STRING);  | 
            ||
| 70 |                     if (!$formIdent) { | 
            ||
| 71 | $formIdent = (isset($adminMetadata['default_form']) ? $adminMetadata['default_form'] : '');  | 
            ||
| 72 | }  | 
            ||
| 73 | |||
| 74 |                     if (isset($adminMetadata['forms'][$formIdent]['label'])) { | 
            ||
| 75 | $title = $translator->translation($adminMetadata['forms'][$formIdent]['label']);  | 
            ||
| 76 | }  | 
            ||
| 77 | }  | 
            ||
| 78 | |||
| 79 |                 if ($objId) { | 
            ||
| 80 |                     if (!$title && isset($metadata['labels']['edit_item'])) { | 
            ||
| 81 | $title = $translator->translation($metadata['labels']['edit_item']);  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 |                     if (!$title && isset($metadata['labels']['edit_model'])) { | 
            ||
| 85 | $title = $translator->translation($metadata['labels']['edit_model']);  | 
            ||
| 86 | }  | 
            ||
| 87 |                 } else { | 
            ||
| 88 |                     if (!$title && isset($metadata['labels']['new_item'])) { | 
            ||
| 89 | $title = $translator->translation($metadata['labels']['new_item']);  | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 |                     if (!$title && isset($metadata['labels']['new_model'])) { | 
            ||
| 93 | $title = $translator->translation($metadata['labels']['new_model']);  | 
            ||
| 94 | }  | 
            ||
| 95 | }  | 
            ||
| 96 | |||
| 97 |                 if (!$title) { | 
            ||
| 98 | $objType = (isset($metadata['labels']['singular_name'])  | 
            ||
| 99 | ? $translator->translation($metadata['labels']['singular_name'])  | 
            ||
| 100 | : null);  | 
            ||
| 101 | |||
| 102 |                     if ($objId) { | 
            ||
| 103 |                         $title = $translator->translation('Edit: {{ objType }} #{{ id }}'); | 
            ||
| 104 |                     } else { | 
            ||
| 105 |                         $title = $translator->translation('Create: {{ objType }}'); | 
            ||
| 106 | }  | 
            ||
| 107 | |||
| 108 |                     if ($objType) { | 
            ||
| 109 | $title = strtr($title, [  | 
            ||
| 110 |                             '{{ objType }}' => $objType | 
            ||
| 111 | ]);  | 
            ||
| 112 | }  | 
            ||
| 113 | }  | 
            ||
| 114 | }  | 
            ||
| 115 | |||
| 116 | $this->title = $this->renderTitle($title);  | 
            ||
| 117 | }  | 
            ||
| 118 | |||
| 119 | return $this->title;  | 
            ||
| 120 | }  | 
            ||
| 247 |