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 ( c440df...acd042 )
by Miles
04:28
created

ValueTypeCheckable::isNumber()   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 0
Metric Value
c 1
b 0
f 0
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     0.2.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 ValueTypeCheckable
27
{
28
29
    /**
30
     * Returns if value is a string
31
     *
32
     * @param string $value The value to test
33
     *
34
     * @return bool Is a value a string
35
     */
36 30
    private function isString($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
37
    {
38 30
        return $this->startsWith('\'', $value) || $this->startsWith('"', $value);
0 ignored issues
show
Bug introduced by
It seems like startsWith() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
39
    }
40
41
    /**
42
     * Returns if value is a bool
43
     *
44
     * @param string $value The value to test
45
     *
46
     * @return bool Is a value a bool
47
     */
48 27
    private function isBool($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
49
    {
50 27
        return in_array(strtolower($value), self::$bool_variants);
51
    }
52
53
    /**
54
     * Returns if value is number
55
     *
56
     * @param string $value The value to test
57
     *
58
     * @return bool Is a value a number
59
     */
60 24
    private function isNumber($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
61
    {
62 24
        return is_numeric($value);
63
    }
64
65
    /**
66
     * Returns if value is null
67
     *
68
     * @param string $value The value to test
69
     *
70
     * @return bool Is a value null
71
     */
72 24
    private function isNull($value)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
73
    {
74 24
        return $value === 'null';
75
    }
76
77
    /**
78
     * Returns if variable value is a clone, e.g. BOOL = $(BOOL_1)
79
     *
80
     * @param string $value         The value to test
81
     * @param array  $matches       The matches of the variables
82
     * @param bool   $quoted_string If the value is in a quoted string
83
     *
84
     * @return bool Is a value null
85
     */
86 6
    private function isVariableClone($value, $matches, $quoted_string)
87
    {
88 6
        return count($matches[0] === 1) && $value == $matches[0][0] && !$quoted_string;
89
    }
90
}