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 ( f78a64...efb4df )
by Miles
09:32
created

Env   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 53
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A parse() 0 6 1
A getContents() 0 4 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     1.1.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;
20
21
/**
22
 * Env core class
23
 *
24
 * @since 0.1.0
25
 */
26
class Env
27
{
28
    /**
29
     * The .env contents
30
     *
31
     * @var array $contents
32
     */
33
    private $contents = array();
34
35
    /**
36
     * Creates a new instance of Env
37
     *
38
     * @param string $file              The .env to parse
39
     * @param bool   $origin_exception  Whether or not to throw ParseException in the .env
40
     *
41
     * @throws \InvalidArgumentException If the file does not exist or is not readable
42
     */
43 66
    public function __construct($file, $origin_exception = false)
44
    {
45 66
        if (!is_file($file) || !is_readable($file)) {
46 3
            throw new \InvalidArgumentException(sprintf('%s is not a file or readable', $file));
47
        }
48
49 63
        $parser = new Parser($file, $origin_exception);
50
51 63
        $this->contents = $parser->parse();
52 42
    }
53
54
    /**
55
     * Parses the .env and returns the contents statically
56
     *
57
     * @param string $file              The .env to parse
58
     * @param bool   $origin_exception  Whether or not to throw ParseException in the .env
59
     *
60
     * @return array The .env contents
61
     */
62 66
    public static function parse($file, $origin_exception = false)
63
    {
64 66
        $env = new Env($file, $origin_exception);
65
66 42
        return $env->getContents();
67
    }
68
69
    /**
70
     * Returns the contents of the .env
71
     *
72
     * @return array The .env contents
73
     */
74 42
    public function getContents()
75
    {
76 42
        return $this->contents;
77
    }
78
}
79