Completed
Push — master ( 5245e6...49a17d )
by
unknown
07:40
created

MapperFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 90.91%
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 20
ccs 10
cts 11
cp 0.9091
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A build() 0 8 2
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Alessandro Cosentino <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @copyright Alessandro Cosentino 2012
11
 * @copyright Bernhard Posselt 2012, 2014
12
 */
13
14
namespace OCA\News\Db;
15
16
use OCP\IDBConnection;
17
18
use OCA\News\Db\Mysql\ItemMapper as MysqlItemMapper;
19
use OCA\News\DependencyInjection\IFactory;
20
21
22
class MapperFactory implements IFactory {
23
24
	private $dbType;
25
	private $db;
26
27 16
	public function __construct(IDBConnection $db, $databaseType) {
28 16
		$this->dbType = $databaseType;
29 16
		$this->db = $db;
30 16
	}
31
32 16
	public function build() {
33 16
		switch($this->dbType) {
34 16
			case 'mysql':
35
				return new MysqlItemMapper($this->db);
36 16
			default:
37 16
				return new ItemMapper($this->db);
38 16
		}
39
	}
40
41
}
42