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.

KeyParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 30
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 18 4
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     2.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\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
     * Parses a .env key
32
     *
33
     * @param string $key The key string
34
     *
35
     * @throws \M1\Env\Exception\ParseException If key contains a character that isn't alphanumeric or a _
36
     *
37
     * @return string|false The parsed key, or false if the key is a comment
38
     */
39 54
    public function parse($key)
40
    {
41 54
        $key = trim($key);
42
43 54
        if ($this->parser->string_helper->startsWith('#', $key)) {
44
            return false;
45
        }
46
47 54
        if (!ctype_alnum(str_replace('_', '', $key)) || $this->parser->string_helper->startsWithNumber($key)) {
48 6
            throw new ParseException(
49 6
                sprintf('Key can only contain alphanumeric and underscores and can not start with a number: %s', $key),
50 6
                $key,
51 6
                $this->parser->line_num
52 6
            );
53
        }
54
55 48
        return $key;
56
    }
57
}
58