Completed
Push — master ( 84470e...c291b9 )
by Ron
03:30
created

ServiceDispatcherBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 11
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A withSQLite() 0 4 1
A withMySQL() 0 4 1
1
<?php
2
namespace Kir\Services\Cmd\Dispatcher;
3
4
use Kir\Services\Cmd\Dispatcher\AttributeRepositories\MySQLAttributeRepository;
5
use Kir\Services\Cmd\Dispatcher\AttributeRepositories\SqliteAttributeRepository;
6
use Kir\Services\Cmd\Dispatcher\Builder\MySQLBuilder;
7
use Kir\Services\Cmd\Dispatcher\Dispatchers\DefaultDispatcher;
8
use PDO;
9
10
class ServiceDispatcherBuilder {
11
	public static function withSQLite(string $filename): DefaultDispatcher {
12
		$repos = new SqliteAttributeRepository(new PDO(sprintf('sqlite:%s', $filename)));
13
		return new DefaultDispatcher($repos);
14
	}
15
	
16
	public static function withMySQL(PDO $pdo, array $options): MySQLBuilder {
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
		$repos = new MySQLAttributeRepository($pdo);
18
		return new DefaultDispatcher($repos);
19
	}
20
}
21