Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#289)
by Owen
02:39
created

Tabs::disableHorizontalTabs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\PanelTraits;
4
5
trait Tabs
6
{
7
    public $tabs = [];
8
    public $tabsHorizontal = true;
9
10
    private function initTabs()
11
    {
12
        if (is_array($this->tabs)) {
13
            $this->tabs = collect([]);
0 ignored issues
show
Documentation Bug introduced by
It seems like collect(array()) of type object<Illuminate\Support\Collection> is incompatible with the declared type array of property $tabs.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
14
            $this->tabsHorizontal = config('backpack.crud.tabs_horizontal', true);
15
        }
16
    }
17
18
    public function enableVerticalTabs()
19
    {
20
        $this->tabsHorizontal = false;
21
22
        return $this->tabsHorizontal;
23
    }
24
25
    public function disableVerticalTabs()
26
    {
27
        $this->tabsHorizontal = true;
28
29
        return $this->tabsHorizontal;
30
    }
31
32
    public function enableHorizontalTabs()
33
    {
34
        $this->tabsHorizontal = true;
35
36
        return $this->tabsHorizontal;
37
    }
38
39
    public function disableHorizontalTabs()
40
    {
41
        $this->tabsHorizontal = false;
42
43
        return $this->tabsHorizontal;
44
    }
45
46
    public function clearTabs()
47
    {
48
        $this->tabs = collect([]);
0 ignored issues
show
Documentation Bug introduced by
It seems like collect(array()) of type object<Illuminate\Support\Collection> is incompatible with the declared type array of property $tabs.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
49
50
        return $this->tabs;
51
    }
52
53
    public function getTabs()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
54
    {
55
        $this->initTabs();
56
57
        return $this->tabs;
58
    }
59
60
    public function addTab($label)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
61
    {
62
        $this->initTabs();
63
64
        $newTab = (object) [
65
            'label' => $label,
66
            'name'  =>  snake_case($label),
67
            'fields' => collect([]),
68
            'horizontal' => $this->tabsHorizontal,
69
        ];
70
71
        $this->tabs->push($newTab);
72
73
        return $newTab;
74
    }
75
76
    public function removeTab($label)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
77
    {
78
        $this->initTabs();
79
80
        $this->tabs = $this->tabs->reject(function ($tab) use ($label) {
81
            return $tab->label == $label;
82
        });
83
84
        return $this->tabs;
85
    }
86
87 View Code Duplication
    public function getCreateTabs()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
88
    {
89
        return $this->tabs->filter(function (&$tab) {
90
91
            $tab->fields = $tab->fields->reject(function ($field) {
92
                return $field['method'] == 'update';
93
            });
94
95
            return $tab->fields->count();
96
        });
97
    }
98
99 View Code Duplication
    public function getUpdateTabs()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
100
    {
101
        return $this->tabs->filter(function (&$tab) {
102
103
            $tab->fields = $tab->fields->reject(function ($field) {
104
                return $field['method'] == 'create';
105
            });
106
107
            return $tab->fields->count();
108
        });
109
    }
110
}
111