Completed
Push — master ( 7c13fc...e13714 )
by Gabriel
04:40
created

AbstractModel::setParameters()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 8.8571
cc 5
eloc 7
nc 5
nop 1
1
<?php
2
3
namespace ByTIC\MFinante\Models;
4
5
use ByTIC\MFinante\Helper;
6
7
/**
8
 * Class AbstractModel
9
 * @package ByTIC\MFinante\Models
10
 */
11
abstract class AbstractModel
12
{
13
14
    /**
15
     * @param array $parameters
16
     */
17
    public function setParameters($parameters)
18
    {
19
        if (is_array($parameters)) {
20
            foreach ($parameters as $name => $value) {
21
                $method = 'set' . ucfirst(Helper::camelCase($name));
22
                if (method_exists($this, $method)) {
23
                    $this->$method($value);
24
                } elseif (property_exists($this, $name)) {
25
                    $this->{$name} = $value;
26
                }
27
            }
28
        }
29
    }
30
}
31