1 | <?php |
||
2 | |||
3 | namespace Itstructure\MFU\Traits; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\Model; |
||
6 | |||
7 | trait OwnerBehavior |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $behaviorValues = []; |
||
13 | |||
14 | /** |
||
15 | * @var bool |
||
16 | */ |
||
17 | protected $removeDependencies = false; |
||
18 | |||
19 | /** |
||
20 | * @param string $attribute |
||
21 | * @param mixed $value |
||
22 | * @return $this |
||
23 | */ |
||
24 | public function setBehaviorValue(string $attribute, $value) |
||
25 | { |
||
26 | $this->behaviorValues[$attribute] = $value; |
||
27 | return $this; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param string $attribute |
||
32 | * @return mixed |
||
33 | */ |
||
34 | public function getBehaviorValue(string $attribute) |
||
35 | { |
||
36 | return $this->behaviorValues[$attribute] ?? null; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param bool $removeDependencies |
||
41 | * @return $this |
||
42 | */ |
||
43 | public function setRemoveDependencies(bool $removeDependencies) |
||
44 | { |
||
45 | $this->removeDependencies = $removeDependencies; |
||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function getRemoveDependencies(): bool |
||
53 | { |
||
54 | return $this->removeDependencies; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param array $attributes |
||
59 | * @return Model |
||
60 | */ |
||
61 | public function fill(array $attributes) |
||
62 | { |
||
63 | foreach (static::getBehaviorAttributes() as $behaviorAttribute) { |
||
0 ignored issues
–
show
|
|||
64 | if (isset($attributes[$behaviorAttribute])) { |
||
65 | $this->setBehaviorValue($behaviorAttribute, $attributes[$behaviorAttribute]); |
||
66 | } |
||
67 | } |
||
68 | return parent::fill($attributes); |
||
69 | } |
||
70 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.