FluentArrayAccess   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
get() 0 1 ?
A offsetExists() 0 4 1
A offsetGet() 0 4 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
1
<?php
2
3
namespace App\Support\Traits;
4
5
trait FluentArrayAccess
6
{
7
    /**
8
     * Get an attribute from the container.
9
     *
10
     * @param  string  $key
11
     * @param  mixed   $default
12
     * @return mixed
13
     */
14
    abstract public function get($key, $default = null);
15
16
    /**
17
     * Determine if the given offset exists.
18
     *
19
     * @param  string  $offset
20
     * @return bool
21
     */
22
    public function offsetExists($offset)
23
    {
24
        return isset($this->attributes[$offset]);
25
    }
26
27
    /**
28
     * Get the value for a given offset.
29
     *
30
     * @param  string  $offset
31
     * @return mixed
32
     */
33
    public function offsetGet($offset)
34
    {
35
        return $this->get($offset);
36
    }
37
38
    /**
39
     * Set the value at the given offset.
40
     *
41
     * @param  string  $offset
42
     * @param  mixed   $value
43
     * @return void
44
     */
45
    public function offsetSet($offset, $value)
46
    {
47
        $this->attributes[$offset] = $value;
48
    }
49
50
    /**
51
     * Unset the value at the given offset.
52
     *
53
     * @param  string  $offset
54
     * @return void
55
     */
56
    public function offsetUnset($offset)
57
    {
58
        unset($this->attributes[$offset]);
59
    }
60
}
61