Model   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 31.25 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 10
loc 32
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fill() 10 11 3
A toArray() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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