Completed
Push — master ( 188ffb...31684b )
by Maxime
02:48
created

LanguageDatatable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 37.04 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 10
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 10 10 1
B setClassRow() 0 12 5

How to fix   Duplicated Code   

Duplicated Code

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 namespace Distilleries\Expendable\Http\Datatables\Language;
2
3
use Distilleries\Expendable\Http\Datatables\BaseDatatable;
4
5
class LanguageDatatable extends BaseDatatable {
6
7 View Code Duplication
    public function build()
8
    {
9
        $this
10
            ->add('id', null, trans('expendable::datatable.id'))
11
            ->add('libelle', null, trans('expendable::datatable.libelle'))
12
            ->add('iso', null, trans('expendable::datatable.iso'));
13
14
        $this->addDefaultAction();
15
16
    }
17
18
19
    public function setClassRow($datatable)
20
    {
21
        $datatable->setRowClass(function($row)
22
        {
23
            $class = (isset($row->status) && empty($row->status)) ? 'danger' : '';
24
            $class = (empty($class) && !empty($row->not_visible)) ? 'warning' : $class;
25
26
            return $class;
27
        });
28
29
        return $datatable;
30
    }
31
}