Passed
Push — master ( 04b495...4a17b9 )
by Jean
01:53
created

ArrayAccessTrait::offsetExists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * ArrayAccessTrait
4
 *
5
 * @package php-deferred-callchain
6
 * @author  Jean Claveau
7
 */
8
namespace JClaveau\Async;
9
use       BadMethodCallException;
10
11
/**
12
 * Trait gathering support of array entries access
13
 */
14
trait ArrayAccessTrait
15
{
16
    /**
17
     * ArrayAccess interface
18
     *
19
     * @param string $key The entry to acces
20
     */
21
    public function &offsetGet($key)
22
    {
23
        $caller = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
24
        
25
        $this->stack[] = [
0 ignored issues
show
Bug Best Practice introduced by
The property stack does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
            'entry' => $key,
27
            'file'  => isset($caller['file']) ? $caller['file'] : null,
28
            'line'  => isset($caller['line']) ? $caller['line'] : null,
29
        ];
30
31
        return $this;
32
    }
33
34
    /**
35
     * Unused part of the ArrayAccess interface
36
     *
37
     * @param  $offset
38
     * @param  $value
39
     * @throws \BadMethodCallException
40
     */
41
    public function offsetSet($offset, $value)
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed. ( Ignorable by Annotation )

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

41
    public function offsetSet(/** @scrutinizer ignore-unused */ $offset, $value)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

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

41
    public function offsetSet($offset, /** @scrutinizer ignore-unused */ $value)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        throw new BadMethodCallException(
44
            "not implemented"
45
        );
46
    }
47
48
    /**
49
     * Unused part of the ArrayAccess interface
50
     *
51
     * @param  $offset
52
     * @throws \BadMethodCallException
53
     */
54
    public function offsetExists($offset)
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed. ( Ignorable by Annotation )

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

54
    public function offsetExists(/** @scrutinizer ignore-unused */ $offset)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
    {
56
        throw new BadMethodCallException(
57
            "not implemented"
58
        );
59
    }
60
61
    /**
62
     * Unused part of the ArrayAccess interface
63
     *
64
     * @param  $offset
65
     * @throws \BadMethodCallException
66
     */
67
    public function offsetUnset($offset)
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed. ( Ignorable by Annotation )

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

67
    public function offsetUnset(/** @scrutinizer ignore-unused */ $offset)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68
    {
69
        throw new BadMethodCallException(
70
            "not implemented"
71
        );
72
    }
73
74
    /**/
75
}
76