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
Pull Request — main (#4854)
by Pedro
40:26 queued 25:42
created

ValidationRules   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 9
c 2
b 1
f 0
dl 0
loc 21
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getRules() 0 3 1
A for() 0 3 1
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Components;
4
5
use Backpack\CRUD\app\Library\Components\Interfaces\AttributeInterface;
6
7
class ValidationRules
8
{
9
    public function __construct(private array $rules)
10
    {
11
        $this->rules = collect($rules)->mapWithKeys(function ($rule, $attribute) {
0 ignored issues
show
Bug introduced by
$rules of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

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

11
        $this->rules = collect(/** @scrutinizer ignore-type */ $rules)->mapWithKeys(function ($rule, $attribute) {
Loading history...
12
            if (is_a($rule, AttributeInterface::class, true)) {
13
                return [$rule::getAttributeName() => $rule::getValidationRules()];
14
            }
15
16
            return [$attribute =>  $rule];
17
        })->toArray();
18
    }
19
20
    public function getRules(): array
21
    {
22
        return $this->rules;
23
    }
24
25
    public function for($attribute)
26
    {
27
        return $this->rules[$attribute] ?? [];
28
    }
29
}
30