Entity::getData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Swader\Diffbot\Abstracts;
4
5
abstract class Entity
6
{
7
    /** @var array */
8
    protected $data;
9
10 190
    public function __construct(array $data)
11
    {
12 190
        $this->data = $data;
13 190
    }
14
15
    /**
16
     * Returns the original response that was passed into the Entity
17
     * @return array
18
     */
19 1
    public function getData()
20
    {
21 1
        return $this->data;
22
    }
23
24 2
    public function __get($name)
25
    {
26 2
        return (isset($this->data[$name])) ? $this->data[$name] : null;
27
    }
28
29 2
    public function __call($name, $arguments)
30
    {
31 2
        $isGetter = substr($name, 0, 3) == 'get';
32 2
        if ($isGetter) {
33 1
            $property = lcfirst(substr($name, 3, strlen($name) - 3));
34 1
            return $this->$property;
35
        }
36
37 1
        throw new \BadMethodCallException('No such method: '.$name);
38
    }
39
}