ArrayAccessTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 51
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 7 1
A offsetUnset() 0 9 1
A offsetGet() 0 7 1
A offsetSet() 0 10 1
A ArrayAccessTrait_unwrap() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Mcneely\Core\Traits;
6
7
use ArrayAccess;
8
use Mcneely\Core\CoreObject;
9
10
/**
11
 * Trait ArrayAccessTrait.
12
 *
13
 * @package Mcneely\Core\Traits
14
 *
15
 * @method mixed setCoreObject_CoreTrait()
16
 * @method CoreObject CoreTrait_getCoreObject()
17
 * @method mixed fireEvents_CoreTrait($eventClassObject, $eventImmediateClass, $eventMethod, $eventTrait)
18
 */
19
trait ArrayAccessTrait
20
{
21 2
    public function offsetExists($offset)
22
    {
23 2
        $this->CoreTrait_fireEvents($this, __CLASS__, __METHOD__, __TRAIT__);
0 ignored issues
show
Bug introduced by
It seems like CoreTrait_fireEvents() 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

23
        $this->/** @scrutinizer ignore-call */ 
24
               CoreTrait_fireEvents($this, __CLASS__, __METHOD__, __TRAIT__);
Loading history...
24
25
        return $this
26 2
            ->ArrayAccessTrait_unwrap()
27 2
            ->offsetExists($offset)
28
            ;
29
    }
30
31 2
    protected function ArrayAccessTrait_unwrap(): ArrayAccess
32
    {
33
        return $this
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->CoreTrait_...rap(ArrayAccess::class) could return the type Traversable which is incompatible with the type-hinted return ArrayAccess. Consider adding an additional type-check to rule them out.
Loading history...
34 2
            ->CoreTrait_getCoreObject()
35 2
            ->unWrap(ArrayAccess::class)
36
            ;
37
    }
38
39 1
    public function offsetGet($offset)
40
    {
41 1
        $this->CoreTrait_fireEvents($this, __CLASS__, __METHOD__, __TRAIT__);
42
43
        return $this
44 1
            ->ArrayAccessTrait_unwrap()
45 1
            ->offsetGet($offset)
46
            ;
47
    }
48
49 1
    public function offsetSet($offset, $value)
50
    {
51 1
        $this->CoreTrait_fireEvents($this, __CLASS__, __METHOD__, __TRAIT__);
52
53
        $this
54 1
            ->ArrayAccessTrait_unwrap()
55 1
            ->offsetSet($offset, $value)
56
        ;
57
58 1
        return $this;
59
    }
60
61 1
    public function offsetUnset($offset)
62
    {
63 1
        $this->CoreTrait_fireEvents($this, __CLASS__, __METHOD__, __TRAIT__);
64
        $this
65 1
            ->ArrayAccessTrait_unwrap()
66 1
            ->offsetUnset($offset)
67
        ;
68
69 1
        return $this;
70
    }
71
}
72