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 ( 5018c7...c440df )
by Miles
03:57
created

KeyParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 34
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 20 3
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\Parser;
20
21
use M1\Env\Exception\ParseException;
22
23
/**
24
 * The key parser for Env
25
 *
26
 * @since 0.2.0
27
 */
28
class KeyParser extends AbstractParser
29
{
30
31
    /**
32
     * Parses a .env key
33
     *
34
     * @param string $key      The key string
35
     * @param int    $line_num The line num of the key
36
     *
37
     * @throws \M1\Env\Exception\ParseException If key contains a character that isn't alphanumeric or a _
38
     *
39
     * @return string|false The parsed key, or false if the key is a comment
40
     */
41 36
    public function parse($key, $line_num)
42
    {
43 36
        $key = trim($key);
44
45 36
        if ($this->startsWith('#', $key)) {
46 3
            return false;
47
        }
48
49 36
        if (!ctype_alnum(str_replace('_', '', $key))) {
50 6
            throw new ParseException(
51 6
                sprintf('Key can only contain alphanumeric and underscores: %s', $key),
52 6
                $this->origin_exception,
53 6
                $this->file,
54 6
                $key,
55
                $line_num
56 6
            );
57
        }
58
59 30
        return $key;
60
    }
61
}