OwnerBehavior::getBehaviorValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
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
Bug introduced by
The method getBehaviorAttributes() does not exist on Itstructure\MFU\Traits\OwnerBehavior. Did you maybe mean getBehaviorValue()? ( Ignorable by Annotation )

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

63
        foreach (static::/** @scrutinizer ignore-call */ getBehaviorAttributes() as $behaviorAttribute) {

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.

Loading history...
64
            if (isset($attributes[$behaviorAttribute])) {
65
                $this->setBehaviorValue($behaviorAttribute, $attributes[$behaviorAttribute]);
66
            }
67
        }
68
        return parent::fill($attributes);
69
    }
70
}