Completed
Push — dev-master ( d1cf50...eebd1b )
by Vijay
08:23
created

Base::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 10
nc 8
nop 2
dl 0
loc 19
rs 9.2
c 2
b 0
f 0
1
<?php
2
3
namespace FFCMS\Models;
4
5
use FFCMS\Traits as Traits;
6
7
/**
8
 * Base Model Class.
9
 *
10
 * @author Vijay Mahrra <[email protected]>
11
 * @copyright (c) Copyright 2016 Vijay Mahrra
12
 * @license GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
13
 */
14
abstract class Base extends \Prefab
15
{
16
    use Traits\Logger,
17
        Traits\Validation;
18
19
    /**
20
     * initialize with array of params, 'db' and 'logger' can be injected
21
     *
22
     * @param array $params
23
     * @param \Log $logger
0 ignored issues
show
Documentation introduced by
Should the type for parameter $logger not be null|\Log?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
24
     */
25
    public function __construct(array $params = [], \Log $logger = null)
26
    {
27
        if (is_object($logger)) {
28
            \Registry::set('logger', $logger);
29
        }
30
        $this->oLog = \Registry::get('logger');
31
32
        if (!array_key_exists('oLog', $params)) {
33
            $this->oLog = \Registry::get('logger');
34
        }
35
36
        foreach ($params as $k => $v) {
37
            $this->$k = $v;
38
        }
39
40
        // save default validation rules and filter rules in-case we add rules
41
        $this->validationRulesDefault = $this->validationRules;
42
        $this->filterRulesDefault     = $this->filterRules;
43
    }
44
}
45