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
Bug
introduced
by
![]() |
|||||
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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
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 |