| Conditions | 3 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 45 | public function doDefault($msg = ''): void |
||
| 46 | { |
||
| 47 | $data = $this->misc->getDatabaseAccessor(); |
||
| 48 | |||
| 49 | $lang = $this->lang; |
||
| 50 | $renderCastContext = static function ($val) use ($lang) { |
||
| 51 | switch ($val) { |
||
| 52 | case 'e': |
||
| 53 | return $lang['strno']; |
||
| 54 | case 'a': |
||
| 55 | return $lang['strinassignment']; |
||
| 56 | |||
| 57 | default: |
||
| 58 | return $lang['stryes']; |
||
| 59 | } |
||
| 60 | }; |
||
| 61 | |||
| 62 | $this->printTrail('database'); |
||
| 63 | $this->printTabs('database', 'casts'); |
||
| 64 | $this->printMsg($msg); |
||
| 65 | |||
| 66 | $casts = $data->getCasts(); |
||
| 67 | |||
| 68 | $columns = [ |
||
| 69 | 'source_type' => [ |
||
| 70 | 'title' => $this->lang['strsourcetype'], |
||
| 71 | 'field' => Decorator::field('castsource'), |
||
| 72 | ], |
||
| 73 | 'target_type' => [ |
||
| 74 | 'title' => $this->lang['strtargettype'], |
||
| 75 | 'field' => Decorator::field('casttarget'), |
||
| 76 | ], |
||
| 77 | 'function' => [ |
||
| 78 | 'title' => $this->lang['strfunction'], |
||
| 79 | 'field' => Decorator::field('castfunc'), |
||
| 80 | 'params' => ['null' => $this->lang['strbinarycompat']], |
||
| 81 | ], |
||
| 82 | 'implicit' => [ |
||
| 83 | 'title' => $this->lang['strimplicit'], |
||
| 84 | 'field' => Decorator::field('castcontext'), |
||
| 85 | 'type' => 'callback', |
||
| 86 | 'params' => ['function' => $renderCastContext, 'align' => 'center'], |
||
| 87 | ], |
||
| 88 | 'comment' => [ |
||
| 89 | 'title' => $this->lang['strcomment'], |
||
| 90 | 'field' => Decorator::field('castcomment'), |
||
| 91 | ], |
||
| 92 | ]; |
||
| 93 | |||
| 94 | $actions = []; |
||
| 95 | |||
| 96 | echo $this->printTable($casts, $columns, $actions, 'casts-casts', $this->lang['strnocasts']); |
||
|
|
|||
| 97 | } |
||
| 118 |