ReferenceListFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 32
c 1
b 0
f 0
dl 0
loc 92
ccs 32
cts 32
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A newCachedReferenceListOutputRenderer() 0 33 1
A newReferenceListOutputRenderer() 0 12 1
1
<?php
2
3
namespace SCI;
4
5
use SMW\Store;
0 ignored issues
show
Bug introduced by
The type SMW\Store 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...
6
use SMW\NamespaceExaminer;
0 ignored issues
show
Bug introduced by
The type SMW\NamespaceExaminer 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...
7
use SMW\Services\ServicesFactory as ApplicationFactory;
0 ignored issues
show
Bug introduced by
The type SMW\Services\ServicesFactory 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 Onoi\Cache\Cache;
9
use Parser;
0 ignored issues
show
Bug introduced by
The type Parser 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
11
/**
12
 * @license GNU GPL v2+
13
 * @since 1.0
14
 *
15
 * @author mwjames
16
 */
17
class ReferenceListFactory {
18
19
	/**
20
	 * @var Store
21
	 */
22
	private $store;
23
24
	/**
25
	 * @var NamespaceExaminer
26
	 */
27
	private $namespaceExaminer;
28
29
	/**
30
	 * @var CitationReferencePositionJournal
31
	 */
32
	private $citationReferencePositionJournal;
33
34
	/**
35
	 * @since  1.0
36
	 *
37
	 * @param Store $store
38
	 * @param NamespaceExaminer $namespaceExaminer
39
	 * @param CitationReferencePositionJournal $citationReferencePositionJournal
40
	 */
41 12
	public function __construct( Store $store, NamespaceExaminer $namespaceExaminer, CitationReferencePositionJournal $citationReferencePositionJournal ) {
42 12
		$this->store = $store;
43 12
		$this->namespaceExaminer = $namespaceExaminer;
44 12
		$this->citationReferencePositionJournal = $citationReferencePositionJournal;
45 12
	}
46
47
	/**
48
	 * @since  1.0
49
	 *
50
	 * @return ReferenceListOutputRenderer
51
	 */
52 11
	public function newReferenceListOutputRenderer() {
53
54 11
		$mwCollaboratorFactory = ApplicationFactory::getInstance()->newMwCollaboratorFactory();
55 11
		$htmlColumnListRenderer = $mwCollaboratorFactory->newHtmlColumnListRenderer();
56
57 11
		$referenceListOutputRenderer = new ReferenceListOutputRenderer(
58 11
			new CitationResourceMatchFinder( $this->store ),
59 11
			$this->citationReferencePositionJournal,
60 11
			$htmlColumnListRenderer
61
		);
62
63 11
		return $referenceListOutputRenderer;
64
	}
65
66
	/**
67
	 * @since  1.0
68
	 *
69
	 * @param MediaWikiContextInteractor $contextInteractor
70
	 * @param Cache $cache
71
	 * @param CacheKeyProvider $cacheKeyProvider
72
	 * @param Options $options
73
	 *
74
	 * @return CachedReferenceListOutputRenderer
75
	 */
76 10
	public function newCachedReferenceListOutputRenderer( MediaWikiContextInteractor $contextInteractor, Cache $cache, CacheKeyProvider $cacheKeyProvider, Options $options ) {
77
78 10
		$referenceListOutputRenderer = $this->newReferenceListOutputRenderer();
79
80 10
		$referenceListOutputRenderer->setNumberOfReferenceListColumns(
81 10
			$options->get( 'numberOfReferenceListColumns' )
0 ignored issues
show
Bug introduced by
$options->get('numberOfReferenceListColumns') of type string is incompatible with the type integer expected by parameter $numberOfReferenceListColumns of SCI\ReferenceListOutputR...fReferenceListColumns(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

81
			/** @scrutinizer ignore-type */ $options->get( 'numberOfReferenceListColumns' )
Loading history...
82
		);
83
84 10
		$referenceListOutputRenderer->setResponsiveMonoColumnCharacterBoundLength(
85 10
			$options->get( 'responsiveMonoColumnCharacterBoundLength' )
0 ignored issues
show
Bug introduced by
$options->get('responsiv...nCharacterBoundLength') of type string is incompatible with the type integer expected by parameter $responsiveMonoColumnCharacterBoundLength of SCI\ReferenceListOutputR...nCharacterBoundLength(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

85
			/** @scrutinizer ignore-type */ $options->get( 'responsiveMonoColumnCharacterBoundLength' )
Loading history...
86
		);
87
88 10
		$referenceListOutputRenderer->setReferenceListType(
89 10
			$options->get( 'referenceListType' )
90
		);
91
92 10
		$referenceListOutputRenderer->setBrowseLinkToCitationResourceVisibility(
93 10
			$options->get( 'browseLinkToCitationResource' )
0 ignored issues
show
Bug introduced by
$options->get('browseLinkToCitationResource') of type string is incompatible with the type boolean expected by parameter $browseLinkToCitationResourceVisibility of SCI\ReferenceListOutputR...ionResourceVisibility(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

93
			/** @scrutinizer ignore-type */ $options->get( 'browseLinkToCitationResource' )
Loading history...
94
		);
95
96 10
		$referenceListOutputRenderer->setCitationReferenceCaptionFormat(
97 10
			$options->get( 'citationReferenceCaptionFormat' )
0 ignored issues
show
Bug introduced by
$options->get('citationReferenceCaptionFormat') of type string is incompatible with the type integer expected by parameter $citationReferenceCaptionFormat of SCI\ReferenceListOutputR...eferenceCaptionFormat(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

97
			/** @scrutinizer ignore-type */ $options->get( 'citationReferenceCaptionFormat' )
Loading history...
98
		);
99
100 10
		$cachedReferenceListOutputRenderer = new CachedReferenceListOutputRenderer(
101 10
			$referenceListOutputRenderer,
102 10
			$contextInteractor,
103 10
			$this->namespaceExaminer,
104 10
			$cache,
105 10
			$cacheKeyProvider
106
		);
107
108 10
		return $cachedReferenceListOutputRenderer;
109
	}
110
111
}
112