Completed
Push — master ( 23095d...54d687 )
by Danilo
02:12
created

EntityAccess::offsetSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpBotFramework\Entities;
4
5
trait EntityAccess {
6
7
    /** \brief Contains the array passed __construct */
8
    private $container;
9
10
    public function __construct($data) {
11
12
        $this->container = $data;
13
14
    }
15
16
    public function offsetSet($offset, $value) {
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed.

This check looks from 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.

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

Loading history...
17
18
    }
19
20
    public function offsetExists($offset) {
21
22
        // Is it set?
23
        return isset($this->container[$offset]);
24
25
    }
26
27
    public function offsetUnset($offset) {
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed.

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

Loading history...
28
29
        // Log a warning
30
31
    }
32
33
    public function offsetGet($offset) {
34
35
        // Get name of the method, the class should have. Like "getText"
36
        $method = Text::camelCase("get $offset");
37
38
        // If it exists, call it and return its return value
39
        if (method_exists($this, $method)) return $this->{$method}();
40
41
        // If not return the data from the array after checking it is set
42
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
43
44
    }
45
46
}
47