popCaseSensitivityFromContext()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Vanderlee\Comprehend\Parser\Terminal;
4
5
use Vanderlee\Comprehend\Core\Context;
6
7
/**
8
 * Classes implementing this can scan.
9
 *
10
 * @author Martijn
11
 */
12
trait CaseSensitiveTrait
13
{
14
    /**
15
     * @var bool
16
     */
17
    private $caseSensitivity = null;
18
19 481
    private function pushCaseSensitivityToContext(Context $context)
20
    {
21 481
        if ($this->caseSensitivity !== null) {
22 30
            $context->pushCaseSensitivity($this->caseSensitivity);
23
        }
24 481
    }
25
26 481
    private function popCaseSensitivityFromContext(Context $context)
27
    {
28 481
        if ($this->caseSensitivity !== null) {
29 30
            $context->popCaseSensitivity();
30
        }
31 481
    }
32
33
    /**
34
     * @param bool $preference
35
     *
36
     * @return $this
37
     */
38 1
    public function setCaseSensitivity($preference)
39
    {
40 1
        $this->caseSensitivity = $preference;
41
42 1
        return $this;
43
    }
44
45 1
    public function caseSensitive()
46
    {
47 1
        $this->caseSensitivity = true;
48
49 1
        return $this;
50
    }
51
52 1
    public function caseInsensitive()
53
    {
54 1
        $this->caseSensitivity = false;
55
56 1
        return $this;
57
    }
58
}
59