FluentArrayAccess::get()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
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