Conditions | 1 |
Paths | 1 |
Total Lines | 70 |
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 |
||
76 | private function getColumns() |
||
77 | { |
||
78 | return [ |
||
79 | [ |
||
80 | 'data' => 'id', |
||
81 | 'name' => 'articles.id', |
||
82 | 'title' => trans('cms::article.datatable.columns.id'), |
||
83 | 'width' => '20px', |
||
84 | ], |
||
85 | [ |
||
86 | 'data' => 'title', |
||
87 | 'name' => 'articles.title', |
||
88 | 'title' => trans('cms::article.datatable.columns.title'), |
||
89 | ], |
||
90 | [ |
||
91 | 'data' => 'alias', |
||
92 | 'name' => 'articles.alias', |
||
93 | 'visible' => false, |
||
94 | ], |
||
95 | [ |
||
96 | 'data' => 'categories.title', |
||
97 | 'title' => trans('cms::article.datatable.columns.category'), |
||
98 | 'visible' => false, |
||
99 | 'data' => 'category_title', |
||
100 | ], |
||
101 | [ |
||
102 | 'data' => 'published', |
||
103 | 'name' => 'articles.published', |
||
104 | 'width' => '20px', |
||
105 | 'title' => '<i class="fa fa-check-circle" data-toggle="tooltip" data-title="' . trans('cms::article.datatable.columns.published') . '"></i>', |
||
106 | ], |
||
107 | [ |
||
108 | 'data' => 'authenticated', |
||
109 | 'name' => 'articles.authenticated', |
||
110 | 'width' => '20px', |
||
111 | 'title' => '<i class="fa fa-key" data-toggle="tooltip" data-title="' . trans('cms::article.datatable.columns.authenticated') . '"></i>', |
||
112 | ], |
||
113 | [ |
||
114 | 'data' => 'order', |
||
115 | 'name' => 'articles.order', |
||
116 | 'width' => '20px', |
||
117 | 'title' => '<i class="fa fa-list" data-toggle="tooltip" data-title="' . trans('cms::article.datatable.columns.order') . '"></i>', |
||
118 | ], |
||
119 | [ |
||
120 | 'data' => 'hits', |
||
121 | 'name' => 'articles.hits', |
||
122 | 'width' => '20px', |
||
123 | 'title' => '<i class="fa fa-eye" data-toggle="tooltip" data-title="' . trans('cms::article.datatable.columns.hits') . '"></i>', |
||
124 | ], |
||
125 | [ |
||
126 | 'data' => 'is_page', |
||
127 | 'name' => 'articles.is_page', |
||
128 | 'title' => trans('cms::article.datatable.columns.is_page'), |
||
129 | ], |
||
130 | [ |
||
131 | 'data' => 'updated_at', |
||
132 | 'name' => 'articles.updated_at', |
||
133 | 'title' => trans('cms::article.datatable.columns.updated_at'), |
||
134 | 'width' => '100px', |
||
135 | ], |
||
136 | [ |
||
137 | 'data' => 'action', |
||
138 | 'title' => trans('cms::article.datatable.columns.action'), |
||
139 | 'width' => '134px', |
||
140 | 'searchable' => false, |
||
141 | 'orderable' => false, |
||
142 | 'className' => 'text-center', |
||
143 | ], |
||
144 | ]; |
||
145 | } |
||
146 | |||
177 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: