TextCriteria::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace KGzocha\Searcher\Criteria;
5
6
/**
7
 * @author Krzysztof Gzocha <[email protected]>
8
 */
9
class TextCriteria implements CriteriaInterface
10
{
11
    /**
12
     * @var string|null
13
     */
14
    private $text;
15
16
    /**
17
     * @param string $text
18
     */
19 9
    public function __construct(string $text = null)
20
    {
21 9
        $this->text = $text;
22 9
    }
23
24
    /**
25
     * @return string|null
26
     */
27 5
    public function getText()
28
    {
29 5
        return $this->text;
30
    }
31
32
    /**
33
     * @param string $text
34
     */
35 7
    public function setText(string $text = null)
36
    {
37 7
        $this->text = $text;
38 7
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 8
    public function shouldBeApplied(): bool
44
    {
45 8
        return $this->text !== null && 0 < mb_strlen($this->text);
46
    }
47
}
48