WikidataQueryFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 6
Bugs 0 Features 1
Metric Value
wmc 3
c 6
b 0
f 1
lcom 1
cbo 7
dl 0
loc 30
ccs 0
cts 14
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A newSimpleQueryService() 0 3 1
A newQuerySerializer() 0 8 1
1
<?php
2
3
namespace WikidataQueryApi;
4
5
use Serializers\DispatchingSerializer;
6
use WikidataQueryApi\Query\Serializers\AroundQuerySerializer;
7
use WikidataQueryApi\Query\Serializers\BetweenQuerySerializer;
8
use WikidataQueryApi\Query\Serializers\ClaimQuerySerializer;
9
use WikidataQueryApi\Query\Serializers\QuerySerializer;
10
use WikidataQueryApi\Query\Serializers\StringQuerySerializer;
11
use WikidataQueryApi\Services\SimpleQueryService;
12
13
/**
14
 * @licence GPLv2+
15
 * @author Thomas Pellissier Tanon
16
 */
17
class WikidataQueryFactory {
18
19
	/**
20
	 * @var WikidataQueryApi
21
	 */
22
	private $api;
23
24
	/**
25
	 * @param WikidataQueryApi $api
26
	 */
27
	public function __construct( WikidataQueryApi $api ) {
28
		$this->api = $api;
29
	}
30
31
	/**
32
	 * @return SimpleQueryService
33
	 */
34
	public function newSimpleQueryService() {
35
		return new SimpleQueryService( $this->api, $this->newQuerySerializer() );
36
	}
37
38
	private function newQuerySerializer() {
39
		return new QuerySerializer( new DispatchingSerializer( [
40
			new ClaimQuerySerializer(),
41
			new StringQuerySerializer(),
42
			new AroundQuerySerializer(),
43
			new BetweenQuerySerializer()
44
		] ) );
45
	}
46
}
47