Completed
Push — master ( 032e9a...f4f4f4 )
by Arjay
05:40
created

Editor   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 148
Duplicated Lines 0 %

Coupling/Cohesion

Components 7
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 7
cbo 0
dl 0
loc 148
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A make() 0 4 1
A scripts() 0 6 1
A instance() 0 6 1
A ajax() 0 6 1
A table() 0 6 1
A fields() 0 6 1
A language() 0 6 1
A template() 0 6 1
1
<?php
2
3
namespace Yajra\DataTables\Html;
4
5
class Editor
6
{
7
    /**
8
     * @var string
9
     */
10
    public $instance = '';
11
12
    /**
13
     * @var string
14
     */
15
    public $ajax = '';
16
17
    /**
18
     * @var string
19
     */
20
    public $table = '';
21
22
    /**
23
     * @var string
24
     */
25
    public $template = '';
26
27
    /**
28
     * @var string
29
     */
30
    public $fields = '';
31
32
    /**
33
     * @var array
34
     */
35
    public $language = [];
36
37
    /**
38
     * @var string
39
     */
40
    public $scripts = '';
41
42
    /**
43
     * Editor constructor.
44
     *
45
     * @param string $instance
46
     */
47
    public function __construct($instance = 'editor')
48
    {
49
        $this->instance = $instance;
50
    }
51
52
    /**
53
     * Make new Editor instance.
54
     *
55
     * @param string $instance
56
     * @return Editor
57
     */
58
    public static function make($instance = 'editor')
59
    {
60
        return new static($instance);
61
    }
62
63
    /**
64
     * Append raw scripts.
65
     *
66
     * @param string $scripts
67
     */
68
    public function scripts($scripts)
69
    {
70
        $this->scripts = $scripts;
71
72
        return $this;
73
    }
74
75
    /**
76
     * Set Editor's variable name / instance.
77
     *
78
     * @param $instance
79
     * @return $this
80
     */
81
    public function instance($instance)
82
    {
83
        $this->instance = $instance;
84
85
        return $this;
86
    }
87
88
    /**
89
     * Set Editor's ajax parameter.
90
     *
91
     * @param string|array $ajax
92
     * @return $this
93
     */
94
    public function ajax($ajax)
95
    {
96
        $this->ajax = $ajax;
0 ignored issues
show
Documentation Bug introduced by
It seems like $ajax can also be of type array. However, the property $ajax is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
97
98
        return $this;
99
    }
100
101
    /**
102
     * Set Editor's table source.
103
     *
104
     * @param string $table
105
     * @return $this
106
     */
107
    public function table($table)
108
    {
109
        $this->table = $table;
110
111
        return $this;
112
    }
113
114
    /**
115
     * Set Editor's fields.
116
     *
117
     * @param array $fields
118
     * @return $this
119
     */
120
    public function fields(array $fields)
121
    {
122
        $this->fields = $fields;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fields of type array is incompatible with the declared type string of property $fields.

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...
123
124
        return $this;
125
    }
126
127
    /**
128
     * Set Editor's language.
129
     *
130
     * @param array $language
131
     * @return $this
132
     */
133
    public function language(array $language)
134
    {
135
        $this->language = $language;
136
137
        return $this;
138
    }
139
140
    /**
141
     * Set Editor's template.
142
     *
143
     * @param string $template
144
     * @return $this
145
     */
146
    public function template($template)
147
    {
148
        $this->template = $template;
149
150
        return $this;
151
    }
152
}
153