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::parse()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 9.4286
cc 3
eloc 12
nc 3
nop 2
crap 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
}