Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php  | 
            ||
| 8 | class SensorDataDataTable extends DataTable  | 
            ||
| 9 | { | 
            ||
| 10 | /**  | 
            ||
| 11 | * Build DataTable class.  | 
            ||
| 12 | *  | 
            ||
| 13 | * @return \Yajra\DataTables\Engines\BaseEngine  | 
            ||
| 14 | */  | 
            ||
| 15 | public function dataTable($query)  | 
            ||
| 25 | |||
| 26 | /**  | 
            ||
| 27 | * Get the query object to be processed by dataTables.  | 
            ||
| 28 | *  | 
            ||
| 29 | * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection  | 
            ||
| 30 | */  | 
            ||
| 31 | public function query()  | 
            ||
| 36 | |||
| 37 | /**  | 
            ||
| 38 | * Optional method if you want to use html builder.  | 
            ||
| 39 | *  | 
            ||
| 40 | * @return \Yajra\DataTables\Html\Builder  | 
            ||
| 41 | */  | 
            ||
| 42 | public function html()  | 
            ||
| 49 | |||
| 50 | /**  | 
            ||
| 51 | * Get columns.  | 
            ||
| 52 | *  | 
            ||
| 53 | * @return array  | 
            ||
| 54 | */  | 
            ||
| 55 | protected function getColumns()  | 
            ||
| 66 | |||
| 67 | /**  | 
            ||
| 68 | * Get builder parameters.  | 
            ||
| 69 | *  | 
            ||
| 70 | * @return array  | 
            ||
| 71 | */  | 
            ||
| 72 | View Code Duplication | protected function getBuilderParameters()  | 
            |
| 90 | |||
| 91 | /**  | 
            ||
| 92 | * Get filename for export.  | 
            ||
| 93 | *  | 
            ||
| 94 | * @return string  | 
            ||
| 95 | */  | 
            ||
| 96 | protected function filename()  | 
            ||
| 100 | }  | 
            ||
| 101 | 
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: