Completed
Pull Request — master (#116)
by Ian
02:55
created

LangFilter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A transform() 0 11 3
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->trans($item['header']);
21 2
        }
22 19
        if (isset($item['text'])) {
23 17
            $item['text'] = $this->langGenerator->trans($item['text']);
24 17
        }
25
26 19
        return $item;
27
    }
28
}
29