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

MapperFactory::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116
Metric Value
dl 0
loc 8
ccs 6
cts 7
cp 0.8571
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
crap 2.0116
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