newSciteParserFunctionDefinition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 39
ccs 23
cts 23
cp 1
rs 9.568
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace SCI;
4
5
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...
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\ParameterProcessorFactory;
0 ignored issues
show
Bug introduced by
The type SMW\ParameterProcessorFactory 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 SCI\Bibtex\BibtexProcessor;
9
use SCI\Bibtex\BibtexParser;
10
use SCI\Bibtex\BibtexAuthorListParser;
11
12
/**
13
 * @license GNU GPL v2+
14
 * @since 1.0
15
 *
16
 * @author mwjames
17
 */
18
class ParserFunctionFactory {
19
20
	/**
21
	 * {{#scite:}}
22
	 *
23
	 * @since  1.0
24
	 *
25
	 * @param NamespaceExaminer $namespaceExaminer
26
	 * @param Options $options
27
	 *
28
	 * @return array
29
	 */
30
	public function newSciteParserFunctionDefinition( NamespaceExaminer $namespaceExaminer, Options $options ) {
31
32 15
		$sciteParserFunctionDefinition = function( $parser ) use( $namespaceExaminer, $options ) {
33
34 15
			$parserData = ApplicationFactory::getInstance()->newParserData(
35 15
				$parser->getTitle(),
36 15
				$parser->getOutput()
37
			);
38
39 15
			$mwCollaboratorFactory = ApplicationFactory::getInstance()->newMwCollaboratorFactory();
40
41 15
			$citationTextTemplateRenderer = new CitationTextTemplateRenderer(
42 15
				$mwCollaboratorFactory->newWikitextTemplateRenderer(),
43 15
				$parser
44
			);
45
46 15
			$mediaWikiNsContentMapper = new MediaWikiNsContentMapper(
47 15
				$mwCollaboratorFactory->newMediaWikiNsContentReader()
48
			);
49
50 15
			$sciteParserFunction = new SciteParserFunction(
51 15
				$parserData,
52 15
				$namespaceExaminer,
53 15
				$citationTextTemplateRenderer,
54 15
				$mediaWikiNsContentMapper,
55 15
				new BibtexProcessor( new BibtexParser(), new BibtexAuthorListParser() )
56
			);
57
58 15
			$sciteParserFunction->setStrictParserValidationState(
59 15
				$options->get( 'enabledStrictParserValidation' )
0 ignored issues
show
Bug introduced by
$options->get('enabledStrictParserValidation') of type string is incompatible with the type boolean expected by parameter $strictParserValidationState of SCI\SciteParserFunction:...ParserValidationState(). ( Ignorable by Annotation )

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

59
				/** @scrutinizer ignore-type */ $options->get( 'enabledStrictParserValidation' )
Loading history...
60
			);
61
62 15
			return $sciteParserFunction->doProcess(
63 15
				ParameterProcessorFactory::newFromArray( func_get_args() ),
64 15
				new PreTextFormatter()
65
			);
66 1
		};
67
68 1
		return [ 'scite', $sciteParserFunctionDefinition, 0 ];
69
	}
70
71
	/**
72
	 * {{#referencelist:}}
73
	 *
74
	 * @since  1.0
75
	 *
76
	 * @return array
77
	 */
78
	public function newReferenceListParserFunctionDefinition() {
79
80 5
		$referenceListParserFunctionDefinition = function( $parser ) {
81
82 5
			$parserData = ApplicationFactory::getInstance()->newParserData(
83 5
				$parser->getTitle(),
84 5
				$parser->getOutput()
85
			);
86
87 5
			$referenceListParserFunction = new ReferenceListParserFunction( $parserData );
88
89 5
			return $referenceListParserFunction->doProcess(
90 5
				ParameterProcessorFactory::newFromArray( func_get_args() )
91
			);
92
		};
93
94
		return [ 'referencelist', $referenceListParserFunctionDefinition, 0 ];
95
	}
96
97
}
98