Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
94.44% covered (success)
94.44%
17 / 18
94.12% covered (success)
94.12%
16 / 17
CRAP
0.00% covered (danger)
0.00%
0 / 1
ConstraintsServices
94.44% covered (success)
94.44%
17 / 18
94.12% covered (success)
94.12%
16 / 17
17.05
0.00% covered (danger)
0.00%
0 / 1
 getService
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getLoggingHelper
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConstraintStore
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConstraintLookup
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCheckResultSerializer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCheckResultDeserializer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getViolationMessageSerializer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getViolationMessageDeserializer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConstraintParameterParser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConnectionCheckerHelper
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRangeCheckerHelper
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSparqlHelper
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTypeCheckerHelper
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDelegatingConstraintChecker
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getResultsSource
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExpiryLock
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getViolationMessageRendererFactory
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace WikibaseQuality\ConstraintReport;
4
5use MediaWiki\MediaWikiServices;
6use WikibaseQuality\ConstraintReport\Api\ExpiryLock;
7use WikibaseQuality\ConstraintReport\Api\ResultsSource;
8use WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker;
9use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper;
10use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
11use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\LoggingHelper;
12use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper;
13use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\SparqlHelper;
14use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper;
15use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageDeserializer;
16use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageRendererFactory;
17use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageSerializer;
18use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultDeserializer;
19use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer;
20
21/**
22 * @license GPL-2.0-or-later
23 */
24class ConstraintsServices {
25
26    public const LOGGING_HELPER = 'WBQC_LoggingHelper';
27    public const CONSTRAINT_STORE = 'WBQC_ConstraintStore';
28    public const CONSTRAINT_LOOKUP = 'WBQC_ConstraintLookup';
29    public const CHECK_RESULT_SERIALIZER = 'WBQC_CheckResultSerializer';
30    public const CHECK_RESULT_DESERIALIZER = 'WBQC_CheckResultDeserializer';
31    public const VIOLATION_MESSAGE_SERIALIZER = 'WBQC_ViolationMessageSerializer';
32    public const VIOLATION_MESSAGE_DESERIALIZER = 'WBQC_ViolationMessageDeserializer';
33    public const CONSTRAINT_PARAMETER_PARSER = 'WBQC_ConstraintParameterParser';
34    public const CONNECTION_CHECKER_HELPER = 'WBQC_ConnectionCheckerHelper';
35    public const RANGE_CHECKER_HELPER = 'WBQC_RangeCheckerHelper';
36    public const SPARQL_HELPER = 'WBQC_SparqlHelper';
37    public const TYPE_CHECKER_HELPER = 'WBQC_TypeCheckerHelper';
38    public const DELEGATING_CONSTRAINT_CHECKER = 'WBQC_DelegatingConstraintChecker';
39    public const RESULTS_SOURCE = 'WBQC_ResultsSource';
40    public const EXPIRY_LOCK = 'WBQC_ExpiryLock';
41    public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory';
42
43    private static function getService( ?MediaWikiServices $services, $name ) {
44        $services ??= MediaWikiServices::getInstance();
45        return $services->getService( $name );
46    }
47
48    public static function getLoggingHelper( ?MediaWikiServices $services = null ): LoggingHelper {
49        return self::getService( $services, self::LOGGING_HELPER );
50    }
51
52    public static function getConstraintStore(
53        ?MediaWikiServices $services = null
54    ): ConstraintStore {
55        return self::getService( $services, self::CONSTRAINT_STORE );
56    }
57
58    public static function getConstraintLookup( ?MediaWikiServices $services = null ): ConstraintLookup {
59        return self::getService( $services, self::CONSTRAINT_LOOKUP );
60    }
61
62    public static function getCheckResultSerializer(
63        ?MediaWikiServices $services = null
64    ): CheckResultSerializer {
65        return self::getService( $services, self::CHECK_RESULT_SERIALIZER );
66    }
67
68    public static function getCheckResultDeserializer(
69        ?MediaWikiServices $services = null
70    ): CheckResultDeserializer {
71        return self::getService( $services, self::CHECK_RESULT_DESERIALIZER );
72    }
73
74    public static function getViolationMessageSerializer(
75        ?MediaWikiServices $services = null
76    ): ViolationMessageSerializer {
77        return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER );
78    }
79
80    public static function getViolationMessageDeserializer(
81        ?MediaWikiServices $services = null
82    ): ViolationMessageDeserializer {
83        return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER );
84    }
85
86    public static function getConstraintParameterParser(
87        ?MediaWikiServices $services = null
88    ): ConstraintParameterParser {
89        return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER );
90    }
91
92    public static function getConnectionCheckerHelper(
93        ?MediaWikiServices $services = null
94    ): ConnectionCheckerHelper {
95        return self::getService( $services, self::CONNECTION_CHECKER_HELPER );
96    }
97
98    public static function getRangeCheckerHelper( ?MediaWikiServices $services = null ): RangeCheckerHelper {
99        return self::getService( $services, self::RANGE_CHECKER_HELPER );
100    }
101
102    public static function getSparqlHelper( ?MediaWikiServices $services = null ): SparqlHelper {
103        return self::getService( $services, self::SPARQL_HELPER );
104    }
105
106    public static function getTypeCheckerHelper( ?MediaWikiServices $services = null ): TypeCheckerHelper {
107        return self::getService( $services, self::TYPE_CHECKER_HELPER );
108    }
109
110    public static function getDelegatingConstraintChecker(
111        ?MediaWikiServices $services = null
112    ): DelegatingConstraintChecker {
113        return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER );
114    }
115
116    public static function getResultsSource( ?MediaWikiServices $services = null ): ResultsSource {
117        return self::getService( $services, self::RESULTS_SOURCE );
118    }
119
120    public static function getExpiryLock( ?MediaWikiServices $services = null ): ExpiryLock {
121        return self::getService( $services, self::EXPIRY_LOCK );
122    }
123
124    public static function getViolationMessageRendererFactory(
125        ?MediaWikiServices $services = null
126    ): ViolationMessageRendererFactory {
127        return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY );
128    }
129
130}