MultiValueSelectionTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isSelectionSelected() 0 3 1
A setValue() 0 5 1
A createClearControlField() 0 3 1
1
<?php
2
3
namespace WebTheory\Saveyour\Field\Abstracts;
4
5
use WebTheory\Saveyour\Field\Type\Hidden;
6
7
trait MultiValueSelectionTrait
8
{
9
    protected function isSelectionSelected(string $value): bool
10
    {
11
        return in_array($value, $this->value);
12
    }
13
14
    /**
15
     * @return $this
16
     */
17
    public function setValue($value): AbstractValuableElement
18
    {
19
        $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...
20
21
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type WebTheory\Saveyour\Field...ultiValueSelectionTrait which is incompatible with the type-hinted return WebTheory\Saveyour\Field...AbstractValuableElement.
Loading history...
22
    }
23
24
    protected function createClearControlField(): Hidden
25
    {
26
        return new Hidden();
27
    }
28
}
29