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

BoolVal::isFalse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.3847

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
ccs 3
cts 11
cp 0.2727
rs 9.8666
cc 1
nc 1
nop 1
crap 1.3847
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