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.

PathTrait::getPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of the m1\vars 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/vars
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/vars/blob/master/LICENSE
16
 * @link        http://github.com/m1/vars/blob/master/README.MD Documentation
17
 */
18
19
namespace M1\Vars\Traits;
20
21
/**
22
 * Path trait gives common operation functions needed for Paths in Vars
23
 *
24
 * @since 0.1.0
25
 */
26
trait PathTrait
27
{
28
    /**
29
     * The base path for the Vars config and cache folders
30
     *
31
     * @var string $path
32
     */
33
    public $path;
34
35
    /**
36
     * Get the path
37
     *
38
     * @return string The path
39
     */
40 75
    public function getPath()
41
    {
42 75
        return $this->path;
43
    }
44
45
    /**
46
     * Set the Vars base path
47
     *
48
     * @param string  $path            The  path to set
49
     * @param boolean $check_writeable Check whether dir is writeable
50
51
     * @throws \InvalidArgumentException If the path does not exist or is not writable
52
     *
53
     * @return \M1\Vars\Vars
54
     */
55 86
    public function setPath($path, $check_writeable = false)
56
    {
57 86
        if (is_null($path)) {
58 83
            return;
59
        }
60
61 77
        if (!is_dir($path) || ($check_writeable && !is_writable($path))) {
62 2
            throw new \InvalidArgumentException(sprintf(
63 2
                "'%s' base path does not exist or is not writable",
64 2
                $path
65
            ));
66
        }
67
68 75
        $this->path = realpath($path);
69 75
        return $this;
70
    }
71
}
72