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.

Controller::ensureIsPhpFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Facade\CodeEditor\Http\Controllers;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Http\Response;
7
8
class Controller
9
{
10
    protected function ensureFileExistInProject(string $filePath)
11
    {
12
        abort_unless(file_exists($filePath), 404, 'Requested file does not exist.');
13
14
        $realPath = realpath($filePath);
15
16
        $realBasePath = realpath(base_path());
17
18
        abort_unless(Str::startsWith($realPath, $realBasePath), 404, 'Requested file was not found in the project.');
19
    }
20
21
    protected function ensureIsPhpFile(string $file, string $contents)
22
    {
23
        abort_unless(Str::endsWith($file, '.php'), Response::HTTP_UNPROCESSABLE_ENTITY, 'Requested file is not a PHP file.');
24
25
        if (Str::endsWith($file, '.blade.php')) {
26
            return;
27
        }
28
29
        abort_unless(Str::startsWith($contents, '<?php'), Response::HTTP_UNPROCESSABLE_ENTITY, 'Requested file does not start with `<?php`.');
30
    }
31
}
32