Test Failed
Push — master ( 8cc230...986bb1 )
by Robin
10:35
created

Model   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
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 49
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A getAttributes() 0 4 1
A getAttributeNames() 0 4 1
A fill() 0 8 2
1
<?php
2
3
namespace Konsulting\JustGivingApiSdk\ResourceClients\Models;
4
5
class Model
6
{
7
    /**
8
     * Allow data to be filled via the constructor.
9
     *
10
     * @param iterable $data
11
     */
12 27
    public function __construct($data = null)
13
    {
14 27
        if (isset($data)) {
15 23
            $this->fill($data);
16
        }
17 27
    }
18
19
    /**
20
     * Get an associative array of the attributes.
21
     *
22
     * @return array
23
     */
24 27
    public function getAttributes()
25
    {
26 27
        return get_object_vars($this);
27
    }
28
29
    /**
30
     * Get the names of the attributes on this model.
31
     *
32
     * @return array
33
     */
34 1
    public function getAttributeNames()
35
    {
36 1
        return array_keys($this->getAttributes());
37
    }
38
39
    /**
40
     * Populate the model with the supplied data.
41
     *
42
     * @param iterable $data
43
     * @return $this
44
     */
45 25
    public function fill($data)
46
    {
47 25
        foreach ($data as $key => $value) {
48 25
            $this->$key = $value;
49
        }
50
51 25
        return $this;
52
    }
53
}
54