GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 8b864d...9c6238 )
by Miles
08:16
created

ValueCheckTrait::isBool()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of the m1\env library
5
 *
6
 * (c) m1 <[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
 * @package     m1/env
12
 * @version     1.0.0
13
 * @author      Miles Croxford <[email protected]>
14
 * @copyright   Copyright (c) Miles Croxford <[email protected]>
15
 * @license     http://github.com/m1/env/blob/master/LICENSE.md
16
 * @link        http://github.com/m1/env/blob/master/README.md Documentation
17
 */
18
19
namespace M1\Env\Traits;
20
21
/**
22
 * The trait for checking types
23
 *
24
 * @since 0.2.0
25
 */
26
trait ValueCheckTrait
27
{
28
    /**
29
     * Returns if value starts with a value
30
     *
31
     * @param string $string The value to search for
32
     * @param string $line   The line to test
33
     *
34
     * @return bool Returns if the line starts with value
35
     */
36 54
    protected function startsWith($string, $line)
37
    {
38 54
        return $string === "" || strrpos($line, $string, -strlen($line)) !== false;
39
    }
40
41
    /**
42
     * Returns if value is a string
43
     *
44
     * @param string $value The value to test
45
     *
46
     * @return bool Is a value a string
47
     */
48 42
    private function isString($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
49
    {
50 42
        return $this->startsWith('\'', $value) || $this->startsWith('"', $value);
51
    }
52
53
    /**
54
     * Returns if value is a bool
55
     *
56
     * @param string $value The value to test
57
     *
58
     * @return bool Is a value a bool
59
     */
60 39
    private function isBool($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
61
    {
62 39
        return in_array(strtolower($value), self::$bool_variants);
63
    }
64
65
    /**
66
     * Returns if the bool is in a string
67
     *
68
     * @param string $value         The value to test
69
     * @param bool   $quoted_string Is the context a quoted string
70
     * @param int    $word_count    The amount of words in the sentence
71
     *
72
     * @return bool Is a value a bool in a string
73
     */
74 12
    private function isBoolInString($value, $quoted_string, $word_count)
75
    {
76 12
        return (is_bool($value)) && ($quoted_string || $word_count >= 2);
77
    }
78
79
    /**
80
     * Returns if value is number
81
     *
82
     * @param string $value The value to test
83
     *
84
     * @return bool Is a value a number
85
     */
86 36
    private function isNumber($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
87
    {
88 36
        return is_numeric($value);
89
    }
90
91
    /**
92
     * Returns if value is null
93
     *
94
     * @param string $value The value to test
95
     *
96
     * @return bool Is a value null
97
     */
98 36
    private function isNull($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
99
    {
100 36
        return $value === 'null';
101
    }
102
103
    /**
104
     * Returns if variable value is a clone, e.g. BOOL = $(BOOL_1)
105
     *
106
     * @param string $value         The value to test
107
     * @param array  $matches       The matches of the variables
108
     * @param bool   $quoted_string If the value is in a quoted string
109
     *
110
     * @return bool Is a value null
111
     */
112 18
    private function isVariableClone($value, $matches, $quoted_string)
113
    {
114 18
        return count($matches[0] === 1) && $value == $matches[0][0] && !$quoted_string;
115
    }
116
}
117