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
|
|||
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 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.