Completed
Push — master ( 060b04...657701 )
by
unknown
04:35
created

MapperFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 4
cts 4
cp 1
rs 10
cc 1
eloc 3
nc 1
nop 2
crap 1
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 16
				return new MysqlItemMapper($this->db);
36
			default:
37
				return new ItemMapper($this->db);
38
		}
39
	}
40
41
}
42