WikidataQueryFactory::newQuerySerializer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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