Styles   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 42.11 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 16
loc 38
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 1
A hideToolBar() 0 6 2
A hideTools() 8 8 2
A hideButtonIcons() 8 8 2

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 Te7aHoudini\LaravelTrix\Pipes;
4
5
use Illuminate\Support\Arr;
6
use Te7aHoudini\LaravelTrix\LaravelTrix;
7
8
class Styles
9
{
10
    public function handle(LaravelTrix $trix, \Closure $next)
11
    {
12
        $this->hideToolBar($trix);
13
        $this->hideTools($trix);
14
        $this->hideButtonIcons($trix);
15
16
        $trix->html = "<laravel-trix-instance-style style='display:none;'> {$trix->html} </laravel-trix-instance-style>";
17
18
        return $next($trix);
19
    }
20
21
    public function hideToolBar($trix)
22
    {
23
        if (Arr::get($trix->config, 'hideToolbar')) {
24
            $trix->html .= "#container-{$trix->config['id']} trix-toolbar{display:none;}";
25
        }
26
    }
27
28 View Code Duplication
    public function hideTools($trix)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $trix->html .= collect(Arr::get($trix->config, 'hideTools', []))
31
            ->map(function ($tool) use ($trix) {
32
                return "#container-{$trix->config['id']} .trix-button-group--$tool";
33
            })
34
            ->implode(',').(Arr::get($trix->config, 'hideTools', []) ? '{display:none;}' : '');
35
    }
36
37 View Code Duplication
    public function hideButtonIcons($trix)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $trix->html .= collect(Arr::get($trix->config, 'hideButtonIcons', []))
40
            ->map(function ($iconClass) use ($trix) {
41
                return "#container-{$trix->config['id']} .trix-button--icon-$iconClass";
42
            })
43
            ->implode(',').(Arr::get($trix->config, 'hideButtonIcons', []) ? '{display:none;}' : '');
44
    }
45
}
46