Completed
Push — master ( 3845e2...a95f7d )
by Danilo
09:37
created

EntityAccess::offsetSet()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 32 and the first side effect is on line 25.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/*
4
 * This file is part of the PhpBotFramework.
5
 *
6
 * PhpBotFramework is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation, version 3.
9
 *
10
 * PhpBotFramework is distributed in the hope that it will be useful, but
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public License
16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace PhpBotFramework\Entities;
20
21
/**
22
 * \addtogroup Core
23
 * @{
24
 */
25
trait EntityAccess
0 ignored issues
show
Bug introduced by
Possible parse error: trait missing opening or closing brace
Loading history...
26
{
27
    /** @} */
28
29
    /** \brief Contains the array passed __construct */
30
    private $container;
31
32
    public function __construct($data)
33
    {
34
        $this->container = $data;
35
    }
36
37
    public function offsetSet($offset, $value)
38
    {
39
    }
40
41
    /** \brief Check that the given offset exists or not */
42
    public function offsetExists($offset)
43
    {
44
<<<<<<< HEAD
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_SL
Loading history...
45
        return isset($this->container[$offset]);
46
    }
47
48
    public function offsetUnset($offset) { /* Log a warning */ }
49
50
    /**
51
     * \brief Get the given offset.
52
     * @param $offset The given offset.
53
     * @return Data relative to the offset.
54
     */
55
    public function offsetGet($offset)
56
    {
57
        // Get name of the method, the class should have. Like "getText"
58
        $method = Text::camelCase("get $offset");
59
60
        // If it exists, call it and return its return value
61
        if (method_exists($this, $method)) {
62
            return $this->{$method}();
63
        }
64
65
        // If not return the data from the array after checking it is set
66
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
67
    }
68
}
69