CaseSensitiveContextTrait::pushCaseSensitivity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 1
f 0
1
<?php
2
3
namespace Vanderlee\Comprehend\Core\Context;
4
5
trait CaseSensitiveContextTrait
6
{
7
    private $caseSensitivity = [];
8
9 513
    public function pushCaseSensitivity($caseSensitive = true)
10
    {
11 513
        $this->caseSensitivity[] = (bool)$caseSensitive;
12 513
    }
13
14 35
    public function popCaseSensitivity()
15
    {
16 35
        return array_pop($this->caseSensitivity);
17
    }
18
19 481
    public function isCaseSensitive()
20
    {
21 481
        return end($this->caseSensitivity);
22
    }
23
24
    // Helper
25 428
    public function handleCase($text)
26
    {
27 428
        return $this->isCaseSensitive()
28 400
            ? $text
29 428
            : mb_strtolower($text);
30
    }
31
}
32