Model::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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