Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CheckResultsRendererFactory | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getCheckResultsRenderer | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare( strict_types = 1 ); |
4 | |
5 | namespace WikibaseQuality\ConstraintReport\Api; |
6 | |
7 | use MediaWiki\Language\Language; |
8 | use MessageLocalizer; |
9 | use Wikibase\Lib\LanguageFallbackChainFactory; |
10 | use Wikibase\Lib\Store\EntityTitleLookup; |
11 | use Wikibase\Repo\EntityIdLabelFormatterFactory; |
12 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Message\ViolationMessageRendererFactory; |
13 | |
14 | /** |
15 | * @license GPL-2.0-or-later |
16 | */ |
17 | class CheckResultsRendererFactory { |
18 | |
19 | private EntityTitleLookup $entityTitleLookup; |
20 | private EntityIdLabelFormatterFactory $entityIdLabelFormatterFactory; |
21 | private LanguageFallbackChainFactory $languageFallbackChainFactory; |
22 | private ViolationMessageRendererFactory $violationMessageRendererFactory; |
23 | |
24 | public function __construct( |
25 | EntityTitleLookup $entityTitleLookup, |
26 | EntityIdLabelFormatterFactory $entityIdLabelFormatterFactory, |
27 | LanguageFallbackChainFactory $languageFallbackChainFactory, |
28 | ViolationMessageRendererFactory $violationMessageRendererFactory |
29 | ) { |
30 | $this->entityTitleLookup = $entityTitleLookup; |
31 | $this->entityIdLabelFormatterFactory = $entityIdLabelFormatterFactory; |
32 | $this->languageFallbackChainFactory = $languageFallbackChainFactory; |
33 | $this->violationMessageRendererFactory = $violationMessageRendererFactory; |
34 | } |
35 | |
36 | public function getCheckResultsRenderer( |
37 | Language $userLanguage, |
38 | MessageLocalizer $messageLocalizer |
39 | ): CheckResultsRenderer { |
40 | $languageFallbackChain = $this->languageFallbackChainFactory->newFromLanguage( $userLanguage ); |
41 | |
42 | return new CheckResultsRenderer( |
43 | $this->entityTitleLookup, |
44 | $this->entityIdLabelFormatterFactory |
45 | ->getEntityIdFormatter( $userLanguage ), |
46 | $languageFallbackChain, |
47 | $this->violationMessageRendererFactory |
48 | ->getViolationMessageRenderer( |
49 | $userLanguage, |
50 | $languageFallbackChain, |
51 | $messageLocalizer |
52 | ) |
53 | ); |
54 | } |
55 | |
56 | } |