ResultSimplifier   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 35
ccs 13
cts 13
cp 1
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A newSubjectCollection() 0 8 2
A newSubject() 0 13 3
A newResultArray() 0 2 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace ModernTimeline\ResultFacade;
6
7
use SMW\DIWikiPage;
0 ignored issues
show
Bug introduced by
The type SMW\DIWikiPage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SMW\Query\PrintRequest;
0 ignored issues
show
Bug introduced by
The type SMW\Query\PrintRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use SMW\Query\QueryResult;
0 ignored issues
show
Bug introduced by
The type SMW\Query\QueryResult was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SMW\Query\Result\ResultArray;
0 ignored issues
show
Bug introduced by
The type SMW\Query\Result\ResultArray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
class ResultSimplifier {
13 4
14 4
	public function newSubjectCollection( QueryResult $result ): SubjectCollection {
15
		$subjects = [];
16 4
17 3
		foreach ( $result->getResults() as $diWikiPage ) {
18
			$subjects[] = $this->newSubject( $diWikiPage, $result->getPrintRequests(), $result );
19
		}
20 4
21
		return SubjectCollection::newFromArray( $subjects );
22
	}
23
24
	/**
25
	 * @param DIWikiPage $resultPage
26
	 * @param PrintRequest[] $printRequests
27
	 * @param QueryResult $result
28
	 * @return Subject
29 3
	 */
30 3
	private function newSubject( DIWikiPage $resultPage, array $printRequests, QueryResult $result ): Subject {
31
		$propertyValueCollections = [];
32 3
33 3
		foreach ( $printRequests as $printRequest ) {
34
			$dataItems = $this->newResultArray( $resultPage, $printRequest, $result )->getContent();
35 3
36 3
			$propertyValueCollections[] = new PropertyValueCollection(
37 3
				$printRequest,
38
				$dataItems === false ? [] : $dataItems
39
			);
40
		}
41 3
42
		return new Subject( $resultPage, $propertyValueCollections );
43
	}
44
45
	private function newResultArray( DIWikiPage $resultPage, PrintRequest $printRequest, QueryResult $result ): ResultArray {
46
		return ResultArray::factory( $resultPage, $printRequest, $result );
47
	}
48 3
49
}
50