Entity   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 35
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getData() 0 4 1
A __get() 0 4 2
A __call() 0 10 2
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
}