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.

Underscore::from()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of Underscore.php
6
 *
7
 * (c) Maxime Fabre <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Underscore;
14
15
use Underscore\Methods\ArraysMethods;
16
use Underscore\Traits\Repository;
17
18
/**
19
 * The base class and wrapper around all other classes.
20
 */
21
class Underscore extends Repository
22
{
23
    /**
24
     * The current config.
25
     */
26
    protected static array $options = [];
27
28
    ////////////////////////////////////////////////////////////////////
29
    //////////////////////////// INTERFACE /////////////////////////////
30
    ////////////////////////////////////////////////////////////////////
31
    /**
32
     * Dispatch to the correct Repository class.
33
     *
34
     * @param mixed $subject The subject
35
     */
36
    public static function from($subject) : Repository
37
    {
38
        $class = Dispatch::toClass($subject);
39
40 3
        return $class::from($subject);
41
    }
42 3
43
    ////////////////////////////////////////////////////////////////////
44 3
    ///////////////////////////// HELPERS //////////////////////////////
45
    ////////////////////////////////////////////////////////////////////
46
47
    /**
48
     * Get an option from the config file.
49
     *
50
     * @param  string  $option  The key of the option
51
     *
52
     * @return mixed Its value
53
     */
54
    public static function option(string $option) : mixed
55
    {
56
        // Get config file
57
        if (!static::$options) {
0 ignored issues
show
Bug Best Practice introduced by
The expression static::options of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
58 34
            static::$options = include __DIR__.'/../config/underscore.php';
59
        }
60
61 34
        return ArraysMethods::get(static::$options, $option);
62
    }
63
}
64