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

Base   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 31
rs 10
c 2
b 0
f 0
wmc 4
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 4
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