Model::fill()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 10
Ratio 90.91 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 10
loc 11
ccs 5
cts 6
cp 0.8333
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3.0416
1
<?php
2
3
namespace Darkgoldblade01\Wordpress\Models;
4
5
/**
6
 * Class Model.
7
 */
8
class Model
9
{
10
    /**
11
     * Fill the Model with
12
     * the data from the array.
13
     *
14
     * @param array $data
15
     *
16
     * @return Model
17
     */
18 2 View Code Duplication
    public function fill(array $data): Model
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20 2
        foreach ($data as $key => $value) {
21 2
            if ($key === 'url') {
22
                continue;
23
            }
24 2
            $this->{$key} = $value;
25
        }
26
27 2
        return $this;
28
    }
29
30
    /**
31
     * Convert the Model to an array.
32
     *
33
     * @return array
34
     */
35 1
    public function toArray(): array
36
    {
37 1
        return (array) $this;
38
    }
39
}
40