Issues (36)

src/Concerns/ResolveDefaults.php (2 issues)

1
<?php
2
3
namespace Larapie\Actions\Concerns;
4
5
use Larapie\Actions\Attribute;
6
7
trait ResolveDefaults
8
{
9 66
    public function default()
10
    {
11 66
        return [];
12
    }
13
14 68
    protected function resolveDefaults()
15
    {
16 68
        return array_merge($this->resolveClassDefaults(), $this->resolveAttributeDefaults());
17
    }
18
19 68
    protected function resolveClassDefaults()
20
    {
21 68
        return $this->default();
22
    }
23
24 68
    protected function resolveAttributeDefaults()
25
    {
26 68
        $defaults = collect($this->rules())
0 ignored issues
show
It seems like rules() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

26
        $defaults = collect($this->/** @scrutinizer ignore-call */ rules())
Loading history...
27 68
            ->filter(function ($rule, $key) {
0 ignored issues
show
The parameter $key 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

27
            ->filter(function ($rule, /** @scrutinizer ignore-unused */ $key) {

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...
28 23
                return $rule instanceof Attribute && $rule->hasDefault();
29 68
            })
30 68
            ->map(function (Attribute $attribute) {
31 4
                return $attribute->getDefault();
32 68
            })
33 68
            ->toArray();
34
35 68
        return $defaults;
36
    }
37
}
38