WikidataQueryFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
nc 1
cc 1
eloc 2
nop 1
crap 2
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