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

Step::previewList()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
c 0
b 0
f 0
nc 3
nop 4
dl 0
loc 21
rs 9.9666
1
<?php
2
3
namespace Backpack\CRUD\app\Console\Commands\Upgrade;
4
5
use Backpack\CRUD\app\Console\Commands\Upgrade\Concerns\ExtractsFirstInteger;
6
7
abstract class Step
8
{
9
    use ExtractsFirstInteger;
10
11
    public function __construct(protected UpgradeContext $context)
12
    {
13
    }
14
15
    abstract public function title(): string;
16
17
    public function description(): ?string
18
    {
19
        return null;
20
    }
21
22
    abstract public function run(): StepResult;
23
24
    protected function context(): UpgradeContext
25
    {
26
        return $this->context;
27
    }
28
29
    public function canFix(StepResult $result): bool
0 ignored issues
show
Unused Code introduced by
The parameter $result is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
    public function canFix(/** @scrutinizer ignore-unused */ StepResult $result): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        return false;
32
    }
33
34
    public function fixMessage(StepResult $result): string
0 ignored issues
show
Unused Code introduced by
The parameter $result is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

34
    public function fixMessage(/** @scrutinizer ignore-unused */ StepResult $result): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    {
36
        return 'Apply automatic fix?';
37
    }
38
39
    public function fix(StepResult $result): StepResult
0 ignored issues
show
Unused Code introduced by
The parameter $result is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function fix(/** @scrutinizer ignore-unused */ StepResult $result): StepResult

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        return StepResult::skipped('No automatic fix available.');
42
    }
43
44
    /**
45
     * Build a preview of items with an optional formatter and overflow message.
46
     *
47
     * @param  array<int, mixed>  $items
48
     * @param  callable|null  $formatter
49
     * @return array<int, string>
50
     */
51
    protected function previewList(
52
        array $items,
53
        int $limit = 10,
54
        ?callable $formatter = null,
55
        ?string $overflowMessage = null
56
    ): array {
57
        if (empty($items)) {
58
            return [];
59
        }
60
61
        $formatter ??= static fn ($item): string => '- '.(string) $item;
62
        $preview = array_slice($items, 0, $limit);
63
        $details = array_map($formatter, $preview);
64
65
        $remaining = count($items) - count($preview);
66
67
        if ($remaining > 0) {
68
            $details[] = sprintf($overflowMessage ?? '... %d more item(s) omitted.', $remaining);
69
        }
70
71
        return $details;
72
    }
73
}
74