Location::__construct()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Distilleries\Contentful\Models;
4
5
/**
6
 * @property string $lon
7
 * @property string $lat
8
 */
9
class Location
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    protected $fillable = [
15
        'lon',
16
        'lat',
17
    ];
18
19
    /**
20
     * Location constructor.
21
     *
22
     * @param  array  $attributes
23
     * @return void
24
     */
25
    public function __construct(array $attributes = [])
26
    {
27
        $this->fill($attributes);
28
    }
29
30
    /**
31
     * Fill the model with an array of attributes.
32
     *
33
     * @param  array  $attributes
34
     * @return $this
35
     */
36
    public function fill(array $attributes)
37
    {
38
        foreach ($this->fillable as $key => $value) {
39
            if (isset($attributes[$value])) {
40
                $this->{$value} = $attributes[$value];
41
            } else {
42
                $this->{$value} = null;
43
            }
44
        }
45
46
        return $this;
47
    }
48
}
49