AttributesManipulation::offsetGet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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