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 ( d1ed4b...44cb20 )
by Pedro
22:30 queued 07:13
created

Step::canFix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
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
     * Provide optional choices for automatic fixes. When empty, a yes/no confirmation is shown.
46
     *
47
     * @return array<int|string, mixed>
48
     */
49
    public function fixOptions(StepResult $result): array
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

49
    public function fixOptions(/** @scrutinizer ignore-unused */ StepResult $result): array

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...
50
    {
51
        return [];
52
    }
53
54
    public function selectFixOption(?string $option): void
0 ignored issues
show
Unused Code introduced by
The parameter $option 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

54
    public function selectFixOption(/** @scrutinizer ignore-unused */ ?string $option): void

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...
55
    {
56
    }
57
58
    public function isBlocking(): bool
59
    {
60
        return false;
61
    }
62
63
    /**
64
     * Build a preview of items with an optional formatter and overflow message.
65
     *
66
     * @param  array<int, mixed>  $items
67
     * @param  callable|null  $formatter
68
     * @return array<int, string>
69
     */
70
    protected function previewList(
71
        array $items,
72
        int $limit = 10,
73
        ?callable $formatter = null,
74
        ?string $overflowMessage = null
75
    ): array {
76
        if (empty($items)) {
77
            return [];
78
        }
79
80
        $formatter ??= static fn ($item): string => '- '.(string) $item;
81
        $preview = array_slice($items, 0, $limit);
82
        $details = array_map($formatter, $preview);
83
84
        $remaining = count($items) - count($preview);
85
86
        if ($remaining > 0) {
87
            $details[] = sprintf($overflowMessage ?? '... %d more item(s) omitted.', $remaining);
88
        }
89
90
        return $details;
91
    }
92
}
93