Completed
Push — master ( 15e507...ea07c8 )
by Camilo
05:47 queued 02:02
created

AbstractFiller   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 80%
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 23
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A populateObject() 0 10 3
A mapSubObjects() 0 4 1
1
<?php
1 ignored issue
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\InternalFunctionality;
6
7
abstract class AbstractFiller
8
{
9 7
    public function __construct(\stdClass $data = null)
10
    {
11 7
        $this->populateObject($data);
12 7
    }
13
14 7
    final protected function populateObject(\stdClass $data = null): AbstractFiller
15
    {
16 7
        if (!is_null($data)) {
17 7
            foreach ($data as $key => $value) {
0 ignored issues
show
Bug introduced by
The expression $data of type object<stdClass> is not traversable.
Loading history...
18 7
                $this->$key = $value;
19
            }
20
        }
21
22 7
        return $this;
23
    }
24
25
    protected function mapSubObjects(): array
26
    {
27
        return [];
28
    }
29
}
30