Completed
Push — master ( de4e4b...4ba19c )
by Mārtiņš
02:06
created

DataMapper::applyValues()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 2
crap 3
1
<?php
2
3
namespace Palladium\Component;
4
5
abstract class DataMapper
6
{
7
8
    /**
9
     * Method for populating the doven instance with values from the array via setters
10
     *
11
     * @param object $instance The object to be populated with values
12
     * @param array $parameters A key-value array, that will be matched to setters
13
     */
14 1 View Code Duplication
    public function applyValues($instance, array $parameters)
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...
15
    {
16 1
        foreach ((array) $parameters as $key => $value) {
17 1
            $method = 'set' . str_replace('_', '', $key);
18 1
            if (method_exists($instance, $method)) {
19 1
                $instance->{$method}($value);
20
            }
21
        }
22 1
    }
23
24
}
25