Completed
Pull Request — master (#4037)
by Muhlis
02:38
created

Tree   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 10
loc 20
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

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
2
3
namespace Tests\Models;
4
5
use Encore\Admin\Traits\AdminBuilder;
6
use Encore\Admin\Traits\ModelTree;
7
use Illuminate\Database\Eloquent\Model;
8
9
class Tree extends Model
10
{
11
    use AdminBuilder, ModelTree;
12
13
    /**
14
     * Create a new Eloquent model instance.
15
     *
16
     * @param array $attributes
17
     */
18
    public function __construct(array $attributes = [])
19
    {
20
        $connection = config('admin.database.connection') ?: config('database.default');
21
22
        $this->setConnection($connection);
23
24
        $this->setTable(config('admin.database.menu_table'));
25
26
        parent::__construct($attributes);
27
    }
28
}
29