Completed
Pull Request — master (#356)
by
unknown
02:33
created

LangFilter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 28.57 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 6
loc 21
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

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 JeroenNoten\LaravelAdminLte\Menu\Filters;
4
5
use Illuminate\Translation\Translator;
6
use JeroenNoten\LaravelAdminLte\Menu\Builder;
7
8
class LangFilter implements FilterInterface
9
{
10
    protected $langGenerator;
11
12 20
    public function __construct(Translator $langGenerator)
13
    {
14 20
        $this->langGenerator = $langGenerator;
15 20
    }
16
17 19
    public function transform($item, Builder $builder)
18
    {
19 19
        if (isset($item['header'])) {
20 2
            $item['header'] = ($this->langGenerator->has('adminlte::menu.'.$item['header'])) ? $this->langGenerator->get('adminlte::menu.'.$item['header'])) : $item['header'];
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ')'
Loading history...
21
        }
22 19
        if (isset($item['text'])) {
23 17
            $item['text'] = ($this->langGenerator->has('adminlte::menu.'.$item['text'])) ? $this->langGenerator->get('adminlte::menu.'.$item['text']) : $tem['text'];
24
        }
25
26 19
        return $item;
27
    }
28
}
29