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
Pull Request — master (#66)
by
unknown
01:14
created

DefectiveConfiguration::getReason()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Spatie\Image\Exceptions;
4
5
use Exception;
6
7
class DefectiveConfiguration extends Exception
8
{
9
10
    public static function getReason()
11
    {
12
        if (! is_dir($dirPath)) {
0 ignored issues
show
Bug introduced by
The variable $dirPath does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
13
            return 'is not a directory';
14
        }
15
16
        if (! is_writable($dirPath)) {
17
            return 'is not writable';
18
        }
19
20
        return 'it seems to be corrupt';
21
    }
22
23
    public static function invalidTemporaryDirectory($dirPath)
24
    {
25
        $reason = self::getReason($dirPath);
0 ignored issues
show
Unused Code introduced by
The call to DefectiveConfiguration::getReason() has too many arguments starting with $dirPath.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
26
        return new self("the temporary directory ${dirPath} is not valid as it {$reason} ");
27
    }
28
}
29