Completed
Push — master ( d129c8...00172d )
by Gabriel
03:56
created

ArrayAccessTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 44
ccs 4
cts 12
cp 0.3333
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A __get() 0 3 1
A offsetSet() 0 3 1
A offsetGet() 0 3 1
A offsetUnset() 0 3 1
1
<?php
2
3
namespace Nip\Http\Request\Traits;
4
5
/**
6
 * Class ArrayAccessTrait
7
 * @package Nip\Http\Request\Traits
8
 */
9
trait ArrayAccessTrait
10
{
11
    /**
12
     * @param mixed $offset
13
     * @return bool
14
     */
15 1
    public function offsetExists($offset)
16
    {
17 1
        return $this->has($offset);
0 ignored issues
show
Bug introduced by
It seems like has() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        return $this->/** @scrutinizer ignore-call */ has($offset);
Loading history...
18
    }
19
20
    /**
21
     * @param mixed $offset
22
     * @return mixed
23
     */
24
    public function offsetGet($offset)
25
    {
26
        return $this->get($offset);
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        return $this->/** @scrutinizer ignore-call */ get($offset);
Loading history...
27
    }
28
29
    /**
30
     * @param mixed $offset
31
     * @param mixed $value
32
     */
33
    public function offsetSet($offset, $value)
34
    {
35
        $this->attributes->set($offset, $value);
0 ignored issues
show
Bug Best Practice introduced by
The property attributes does not exist on Nip\Http\Request\Traits\ArrayAccessTrait. Since you implemented __get, consider adding a @property annotation.
Loading history...
36
    }
37
38
    /**
39
     * @param mixed $offset
40
     */
41
    public function offsetUnset($offset)
42
    {
43
        $this->attributes->remove($offset);
0 ignored issues
show
Bug Best Practice introduced by
The property attributes does not exist on Nip\Http\Request\Traits\ArrayAccessTrait. Since you implemented __get, consider adding a @property annotation.
Loading history...
44
    }
45
46
    /**
47
     * @param $name
48
     * @return mixed
49
     */
50 1
    public function __get($name)
51
    {
52 1
        return $this->get($name);
53
    }
54
}
55