Test Setup Failed
Push — 0.9 ( dd36a2 )
by Ben
05:07
created

AssociatedAsset::hasData()   A

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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Thinktomorrow\AssetLibrary;
4
5
use Illuminate\Database\Eloquent\Relations\MorphPivot;
6
use Illuminate\Support\Arr;
7
8
class AssociatedAsset extends MorphPivot
9
{
10
    public $guarded = [];
11
    protected $casts = [
12
        'data' => 'array',
13
    ];
14
15
    public function hasData(string $key): bool
16
    {
17
        return Arr::has($this->data, $key);
18
    }
19
20
    public function getData(string $key, $default = null)
21
    {
22
        return Arr::get($this->data, $key, $default);
23
    }
24
25
    public function setData(string $name, $value): self
26
    {
27
        $data = $this->data;
28
29
        Arr::set($data, $name, $value);
30
31
        $this->data = $data;
0 ignored issues
show
Bug introduced by
The property data does not seem to exist on Thinktomorrow\AssetLibrary\AssociatedAsset. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
32
33
        return $this;
34
    }
35
36
    public function forgetData(string $name): self
37
    {
38
        $data = $this->data;
39
40
        Arr::forget($data, $name);
41
42
        $this->data = $data;
0 ignored issues
show
Bug introduced by
The property data does not seem to exist on Thinktomorrow\AssetLibrary\AssociatedAsset. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
43
44
        return $this;
45
    }
46
}
47