Model::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Darkgoldblade01\Dnd5eApi\Models;
4
5
/**
6
 * Class Model
7
 * @package Darkgoldblade01\Dnd5eApi\Models
8
 */
9
class Model
10
{
11
12
    /**
13
     * Fill the Model with
14
     * the data from the array.
15
     *
16
     * @param array $data
17
     *
18
     * @return Model
19
     */
20
    public function fill(array $data): Model
21
    {
22
        foreach($data AS $key => $value) {
23
            if($key === 'url') {
24
                continue;
25
            }
26
            $this->{$key} = $value;
27
        }
28
        return $this;
29
    }
30
31
    /**
32
     * Convert the Model to an array
33
     *
34
     * @return array
35
     */
36
    public function toArray(): array
37
    {
38
        return (array) $this;
39
    }
40
41
}
42