Passed
Push — master ( 429320...4248bd )
by Chris
03:24
created

MultiValueSelectionTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 46
ccs 0
cts 10
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isSelectionSelected() 0 3 1
A setValue() 0 5 1
A getClearControl() 0 3 1
A setClearControl() 0 5 1
1
<?php
2
3
namespace WebTheory\Saveyour\Concerns;
4
5
trait MultiValueSelectionTrait
6
{
7
    /**
8
     *
9
     */
10
    protected function isSelectionSelected(string $value): bool
11
    {
12
        return in_array($value, $this->value);
13
    }
14
15
    /**
16
     * Set the value of value
17
     *
18
     * @param mixed $value
19
     *
20
     * @return self
21
     */
22
    public function setValue($value)
23
    {
24
        $this->value = (array) $value;
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
26
        return $this;
27
    }
28
29
    /**
30
     * Get value for hidden input that facilitates unsetting all values on the server
31
     *
32
     * @return string
33
     */
34
    public function getClearControl(): string
35
    {
36
        return $this->clearControl;
37
    }
38
39
    /**
40
     * Set value for hidden input that facilitates unsetting all values on the server
41
     *
42
     * @param string
43
     *
44
     * @return self
45
     */
46
    public function setClearControl(string $clearControl)
47
    {
48
        $this->clearControl = $clearControl;
0 ignored issues
show
Bug Best Practice introduced by
The property clearControl does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
49
50
        return $this;
51
    }
52
}
53