Completed
Push — PSR-11-2 ( a5ad88...7f5041 )
by Nikolaos
03:59
created

BoolVal   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 27.27%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 42
c 0
b 0
f 0
ccs 6
cts 22
cp 0.2727
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isFalse() 0 12 1
A isTrue() 0 12 1
1
<?php
2
3
/**
4
 * This file is part of the Phalcon.
5
 *
6
 * (c) Phalcon Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Phalcon\Helper;
15
16
 /**
17
 * This class offers quick boolean functions throughout the framework
18
 */
19
class BoolVal
20
{
21
    /**
22
     * Checks if the passed value is false
23
     *
24
     * @param mixed $input
25
     *
26
     * @return bool
27
     */
28 1
    final public static function isFalse($input): bool
29
    {
30
        $false = [
31 1
            '0'     => 1,
32
            'f'     => 1,
33
            'false' => 1,
34
            'n'     => 1,
35
            'no'    => 1,
36
        ];
37
38 1
        return isset($false[Str::lower((string) $input)]);
39
    }
40
41
    /**
42
     * Checks if the passed value is true
43
     *
44
     * @param mixed $input
45
     *
46
     * @return bool
47
     */
48 1
    final public static function isTrue($input): bool
49
    {
50
        $false = [
51 1
            '1'    => 1,
52
            'true' => 1,
53
            't'    => 1,
54
            'y'    => 1,
55
            'yes'  => 1,
56
        ];
57
58 1
        return isset($false[Str::lower((string) $input)]);
59
    }
60
}
61