Passed
Push — master ( 446c00...d7e047 )
by Chris
02:29
created

MultiValueSelectionTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createClearControlField() 0 3 1
A isSelectionSelected() 0 3 1
A setValue() 0 5 1
1
<?php
2
3
namespace WebTheory\Saveyour\Concerns;
4
5
use WebTheory\Saveyour\Fields\Hidden;
6
7
trait MultiValueSelectionTrait
8
{
9
    /**
10
     *
11
     */
12
    protected function isSelectionSelected(string $value): bool
13
    {
14
        return in_array($value, $this->value);
15
    }
16
17
    /**
18
     * Set the value of value
19
     *
20
     * @param mixed $value
21
     *
22
     * @return self
23
     */
24
    public function setValue($value)
25
    {
26
        $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...
27
28
        return $this;
29
    }
30
31
    /**
32
     *
33
     */
34
    protected function createClearControlField(): Hidden
35
    {
36
        return new Hidden();
37
    }
38
}
39