ArrayAccessTrait::offsetUnset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 2
b 0
f 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Nip\Http\Request\Traits;
5
6
/**
7
 * Class ArrayAccessTrait
8
 * @package Nip\Http\Request\Traits
9
 */
10
trait ArrayAccessTrait
11
{
12
    /**
13
     * @param mixed $offset
14
     * @return bool
15 1
     */
16
    public function offsetExists($offset): bool
17 1
    {
18
        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

18
        return $this->/** @scrutinizer ignore-call */ has($offset);
Loading history...
19
    }
20
21
    /**
22
     * @param mixed $offset
23
     * @return mixed
24
     */
25
    public function offsetGet($offset): mixed
26
    {
27
        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

27
        return $this->/** @scrutinizer ignore-call */ get($offset);
Loading history...
28
    }
29
30
    /**
31
     * @param mixed $offset
32
     * @param mixed $value
33
     */
34
    public function offsetSet($offset, $value): void
35
    {
36
        $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...
37
    }
38
39
    /**
40
     * @param mixed $offset
41
     */
42
    public function offsetUnset($offset): void
43
    {
44
        $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...
45
    }
46
47
    /**
48
     * @param $name
49
     * @return mixed
50 1
     */
51
    public function __get($name)
52 1
    {
53
        return $this->get($name);
54
    }
55
}
56