mapper_factory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 1
A __construct() 0 4 1
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2015 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\model;
11
12
use blitze\sitemaker\model\mapper_factory_interface;
0 ignored issues
show
Bug introduced by
The type blitze\sitemaker\model\mapper_factory_interface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class mapper_factory implements mapper_factory_interface
15
{
16
	/** @var \phpbb\db\driver\driver_interface */
17
	protected $db;
18
19
	/** @var array */
20
	protected $mapper_tables;
21
22
	/**
23
	 * Constructor
24
	 *
25
	 * @param \phpbb\db\driver\driver_interface		$db			Database object
26
	 * @param array									$tables		Tables for data mapping
27
	 */
28 29
	public function  __construct(\phpbb\db\driver\driver_interface $db, array $tables)
29
	{
30 29
		$this->db = $db;
31 29
		$this->mapper_tables = array_shift($tables);
32 29
	}
33
34
	/**
35
	 * {@inheritdoc}
36
	 */
37 24
	public function create($type)
38
	{
39 24
		$mapper_class = 'blitze\\content\\model\\mapper\\' . $type;
40 24
		$collection = 'blitze\\content\\model\\collections\\' . $type;
41
42 24
		return new $mapper_class($this->db, new $collection, $this, $this->mapper_tables[$type]);
43
	}
44
}
45