Base   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A __construct() 0 7 2
A loadConfig() 0 8 3
1
<?php
2
namespace Ext;
3
4
5
abstract class Base extends SerializableObject
6
{
7
8
	public static function create($config = array()){
9
		return new static($config);
10
	}
11
12
	function __construct(array $config=array())
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
13
	{
14
		if($config){
0 ignored issues
show
Bug Best Practice introduced by
The expression $config of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
15
			$this->loadConfig($config);
16
		}
17
18
	}
19
20
	private function loadConfig($config){
21
		foreach($config as $key=>$value){
22
			$method = 'set'.ucfirst($key);
23
			if(method_exists($this,$method)){
24
				$this->{$method}($value);
25
			}
26
		}
27
	}
28
29
30
}