AttributesManipulation   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 47
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetSet() 0 3 1
A offsetExists() 0 3 1
A offsetUnset() 0 3 1
A get() 0 3 1
A toArray() 0 3 1
A offsetGet() 0 3 1
1
<?php
2
3
namespace NovaFlexibleContent\Layouts\LayoutTraits;
4
5
use Illuminate\Database\Eloquent\Concerns\HasAttributes;
6
7
trait AttributesManipulation
8
{
9
    use HasAttributes;
10
11
    /**
12
     * Convert the model instance to an array.
13
     */
14 1
    public function toArray(): array
15
    {
16 1
        return $this->attributesToArray();
17
    }
18
19 2
    public function get($key, $default = null)
0 ignored issues
show
Unused Code introduced by
The parameter $default 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

19
    public function get($key, /** @scrutinizer ignore-unused */ $default = null)

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...
20
    {
21 2
        return $this->getAttribute($key);
22
    }
23
24
    /**
25
     * Determine if the given attribute exists.
26
     */
27 7
    public function offsetExists(mixed $offset): bool
28
    {
29 7
        return !is_null($this->getAttribute($offset));
30
    }
31
32
    /**
33
     * Get the value for a given offset.
34
     */
35 5
    public function offsetGet(mixed $offset): mixed
36
    {
37 5
        return $this->getAttribute($offset);
38
    }
39
40
    /**
41
     * Set the value for a given offset.
42
     */
43 4
    public function offsetSet(mixed $offset, mixed $value): void
44
    {
45 4
        $this->setAttribute($offset, $value);
46
    }
47
48
    /**
49
     * Unset the value for a given offset.
50
     */
51 2
    public function offsetUnset(mixed $offset): void
52
    {
53 2
        unset($this->attributes[$offset]);
54
    }
55
}
56