Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — add-update-command ( 60d3c1...c664f4 )
by Pedro
14:19
created

InteractsWithCrudControllers   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 40
rs 10
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
B filterCrudControllerPaths() 0 27 7
A isCrudControllerPath() 0 3 1
1
<?php
2
3
namespace Backpack\CRUD\app\Console\Commands\Upgrade\Concerns;
4
5
use Backpack\CRUD\app\Console\Commands\Upgrade\UpgradeContext;
6
7
/**
8
 * @mixin \Backpack\CRUD\app\Console\Commands\Upgrade\Step
9
 */
10
trait InteractsWithCrudControllers
11
{
12
    /**
13
     * Filter a list of file paths to those that look like CrudControllers and optionally validate contents.
14
     */
15
    protected function filterCrudControllerPaths(array $paths, ?callable $contentsValidator = null): array
16
    {
17
        if (empty($paths)) {
18
            return [];
19
        }
20
21
        $filtered = [];
22
23
        foreach ($paths as $path) {
24
            if (! $this->isCrudControllerPath($path)) {
25
                continue;
26
            }
27
28
            $contents = $this->context()->readFile($path);
29
30
            if ($contents === null) {
31
                continue;
32
            }
33
34
            if ($contentsValidator !== null && $contentsValidator($contents, $path) !== true) {
35
                continue;
36
            }
37
38
            $filtered[] = $path;
39
        }
40
41
        return $filtered;
42
    }
43
44
    protected function isCrudControllerPath(string $path): bool
45
    {
46
        return str_contains($path, 'CrudController');
47
    }
48
49
    abstract protected function context(): UpgradeContext;
50
}
51