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 — v6 (#4971)
by Pedro
30:02 queued 15:18
created

MacroableWithAttributes::getMacros()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Backpack\CRUD\app\Library\CrudPanel\Traits\Support;
4
5
use Illuminate\Support\Traits\Macroable;
6
7
trait MacroableWithAttributes
8
{
9
    use Macroable {
10
        __call as macroCall;
11
    }
12
13
    /**
14
     * The registered string macros.
15
     *
16
     * @var array
17
     */
18
    protected static $macros = [];
19
20
    /**
21
     * Get the registered macros.
22
     *
23
     * @var array
24
     */
25
    public function getMacros()
26
    {
27
        return static::$macros;
28
    }
29
30
    /**
31
     * Call the macros registered for the given macroable attributes.
32
     */
33
    public function callRegisteredAttributeMacros(): self
34
    {
35
        $macros = $this->getMacros();
36
        $attributes = $this->getAttributes();
0 ignored issues
show
Bug introduced by
The method getAttributes() does not exist on Backpack\CRUD\app\Librar...MacroableWithAttributes. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

36
        /** @scrutinizer ignore-call */ 
37
        $attributes = $this->getAttributes();
Loading history...
37
38
        foreach (array_keys($macros) as $macro) {
39
            if (isset($attributes[$macro])) {
40
                is_array($attributes[$macro]) ? $this->{$macro}($attributes[$macro]) : $this->{$macro}([]);
41
                continue;
42
            }
43
            if (isset($attributes['subfields'])) {
44
                $subfieldsWithMacros = collect($attributes['subfields'])
45
                                        ->filter(fn ($item) => isset($item[$macro]));
46
47
                $subfieldsWithMacros->each(
48
                    function ($item) use ($subfieldsWithMacros, $macro) {
49
                        $config = ! is_array($item[$macro]) ? [] : $item[$macro];
50
                        if ($subfieldsWithMacros->last() === $item) {
51
                            $this->{$macro}($config, $item);
52
                        } else {
53
                            $this->{$macro}($config, $item, false);
54
                        }
55
                    }
56
                );
57
            }
58
        }
59
60
        return $this;
61
    }
62
}
63