QueryResultFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace SEQL;
4
5
use SEQL\ByHttpRequest\JsonResponseParser;
6
use SEQL\ByHttpRequest\QueryResult as ByHttpRequestQueryResult;
7
use SMW\Store;
8
use SMWQuery as Query;
9
use SMWQueryResult as QueryResult;
10
11
/**
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class QueryResultFactory {
18
19
	/**
20
	 * @var
21
	 */
22
	private $store;
23
24
	/**
25
	 * @since 1.0
26
	 *
27
	 * @param Store $store
28
	 */
29 3
	public function __construct( Store $store ) {
30 3
		$this->store = $store;
31 3
	}
32
33
	/**
34
	 * @since 1.0
35
	 *
36
	 * @param Query $query
37
	 *
38
	 * @return QueryResult
39
	 */
40 1
	public function newEmptyQueryResult( Query $query ) {
41 1
		return new QueryResult(
42 1
			$query->getDescription()->getPrintrequests(),
43 1
			$query,
44 1
			array(),
45 1
			$this->store,
46
			false
47 1
		);
48
	}
49
50
	/**
51
	 * @since 1.0
52
	 *
53
	 * @param Query $query
54
	 * @param JsonResponseParser $jsonResponseParser
55
	 *
56
	 * @return QueryResult
57
	 */
58 1
	public function newByHttpRequestQueryResult( Query $query, JsonResponseParser $jsonResponseParser ) {
59
60 1
		$queryResult = new ByHttpRequestQueryResult(
61 1
			$query->getDescription()->getPrintrequests(),
62 1
			$query,
63 1
			$jsonResponseParser->getResultSubjectList(),
64 1
			$this->store,
65 1
			$jsonResponseParser->hasFurtherResults()
66 1
		);
67
68 1
		$queryResult->setJsonResponseParser( $jsonResponseParser );
69
70 1
		return $queryResult;
71
	}
72
73
}
74