Test Setup Failed
Branch botk5 (03a709)
by Enrico
02:14
created

FactsFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 23
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 4
A factualize() 0 9 1
1
<?php
2
namespace BOTK;
3
4
class FactsFactory implements FactsFactoryInterface {
5
	
6
	private $profile;
7
	
8
	public function __construct( array $profile)
9
	{
10
		assert(!empty($profile['model']) && class_exists('\BOTK\Model\\'.$profile['model']));
11
		assert(isset($profile['datamapper']) && is_callable($profile['datamapper']));
12
		assert(isset($profile['options']) && is_array($profile['options']));
13
		$this->profile = $profile;
14
	}
15
	
16
	public function factualize( array $rawData){
17
		$data = array();
0 ignored issues
show
Unused Code introduced by
$data is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
18
		$numOfRawData = count($rawData);
0 ignored issues
show
Unused Code introduced by
$numOfRawData is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
19
		$datamapper = $this->profile['datamapper'];
20
		$class = '\BOTK\Model\\'.$this->profile['model'];
21
		$data = $datamapper($rawData);
22
		
23
		return new $class($data,$this->profile['options']);
24
	}
25
26
}