FilterEntry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 38
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A setValue() 0 4 1
A toString() 0 6 2
1
<?php
2
3
namespace kalanis\kw_filter;
4
5
6
/**
7
 * Class FilterEntry
8
 * @package kalanis\kw_filter
9
 * Basic filter by entry value
10
 */
11
class FilterEntry extends AFilterEntry
12
{
13
    protected static $relations = [
14
        self::RELATION_EQUAL,
15
        self::RELATION_NOT_EQUAL,
16
        self::RELATION_LESS,
17
        self::RELATION_LESS_EQ,
18
        self::RELATION_MORE,
19
        self::RELATION_MORE_EQ,
20
        self::RELATION_EMPTY,
21
        self::RELATION_NOT_EMPTY,
22
    ];
23
24
    /** @var string */
25
    protected $value = '';
26
27 10
    public function setValue($value): Interfaces\IFilterEntry
28
    {
29 10
        $this->value = $this->toString($value);
30 10
        return $this;
31
    }
32
33
    /**
34
     * @param string|string[]|Interfaces\IFilterEntry $value
35
     * @return string
36
     */
37 10
    protected function toString($value): string
38
    {
39 10
        if (is_array($value)) {
40 2
            return strval(reset($value));
41
        } else {
42 8
            return strval($value);
43
        }
44
    }
45
46 7
    public function getValue()
47
    {
48 7
        return $this->value;
49
    }
50
}
51