Passed
Push — master ( deb522...4fcdf3 )
by Gabriel
02:32
created

CheckLoadedFunctionsTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 13
c 1
b 0
f 1
dl 0
loc 55
rs 10
ccs 6
cts 18
cp 0.3333

6 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 4 1
A filter() 0 4 1
A offsetUnset() 0 4 1
A offsetGet() 0 4 1
A count() 0 4 1
A offsetSet() 0 4 1
1
<?php
2
3
namespace Nip\Collections\Lazy\Traits;
4
5
/**
6
 * Trait CheckLoadedFunctionsTrait
7
 * @package Nip\Collections\Lazy\Traits
8
 * @internal
9
 */
10
trait CheckLoadedFunctionsTrait
11
{
12
    /**
13
     * @inheritDoc
14
     */
15 1
    public function offsetSet($key, $value)
16
    {
17 1
        $this->load();
0 ignored issues
show
Bug introduced by
It seems like load() 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
        $this->/** @scrutinizer ignore-call */ 
18
               load();
Loading history...
18 1
        return parent::offsetSet($key, $value);
19
    }
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function offsetGet($key)
25
    {
26
        $this->load();
27
        return parent::offsetGet($key);
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function offsetExists($key)
34
    {
35
        $this->load();
36
        return parent::offsetExists($key);
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function offsetUnset($key)
43
    {
44
        $this->load();
45
        return parent::offsetUnset($key);
46
    }
47
48
    /**
49
     * @inheritDoc
50
     */
51
    public function filter(callable $callback = null)
52
    {
53
        $this->load();
54
        return parent::filter($callback);
55
    }
56
57
58
    /**
59
     * @inheritDoc
60
     */
61 2
    public function count()
62
    {
63 2
        $this->load();
64 2
        return parent::count();
65
    }
66
}