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

LangFilter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

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
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 JeroenNoten\LaravelAdminLte\Menu\Builder;
6
use Illuminate\Contracts\Translation\Translator;
7
8
class LangFilter implements FilterInterface
9
{
10
    protected $langGenerator;
11
12
    public function __construct(Translator $langGenerator)
13
    {
14
        $this->langGenerator = $langGenerator;
15
    }
16
17
    public function transform($item, Builder $builder)
18
    {
19
        if (isset($item['header'])) {
20
            $item['header'] = $this->langGenerator->trans($item['header']);
21
        }
22
        if (isset($item['text'])) {
23
            $item['text'] = $this->langGenerator->trans($item['text']);
24
        }
25
26
        return $item;
27
    }
28
}
29