Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
13 / 13 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
FormatterFactory | |
100.00% |
13 / 13 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
getStatusFormatter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getBlockErrorFormatter | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Language; |
4 | |
5 | use MediaWiki\Block\BlockErrorFormatter; |
6 | use MediaWiki\HookContainer\HookContainer; |
7 | use MediaWiki\Languages\LanguageFactory; |
8 | use MediaWiki\Status\StatusFormatter; |
9 | use MediaWiki\Title\TitleFormatter; |
10 | use MediaWiki\User\UserIdentityUtils; |
11 | use MessageCache; |
12 | use MessageLocalizer; |
13 | |
14 | /** |
15 | * Factory for formatters of common complex objects |
16 | * |
17 | * @since 1.42 |
18 | */ |
19 | class FormatterFactory { |
20 | |
21 | private MessageCache $messageCache; |
22 | private TitleFormatter $titleFormatter; |
23 | private HookContainer $hookContainer; |
24 | private UserIdentityUtils $userIdentityUtils; |
25 | private LanguageFactory $languageFactory; |
26 | |
27 | public function __construct( |
28 | MessageCache $messageCache, |
29 | TitleFormatter $titleFormatter, |
30 | HookContainer $hookContainer, |
31 | UserIdentityUtils $userIdentityUtils, |
32 | LanguageFactory $languageFactory |
33 | ) { |
34 | $this->messageCache = $messageCache; |
35 | $this->titleFormatter = $titleFormatter; |
36 | $this->hookContainer = $hookContainer; |
37 | $this->userIdentityUtils = $userIdentityUtils; |
38 | $this->languageFactory = $languageFactory; |
39 | } |
40 | |
41 | public function getStatusFormatter( MessageLocalizer $messageLocalizer ): StatusFormatter { |
42 | return new StatusFormatter( $messageLocalizer, $this->messageCache ); |
43 | } |
44 | |
45 | public function getBlockErrorFormatter( LocalizationContext $context ): BlockErrorFormatter { |
46 | return new BlockErrorFormatter( |
47 | $this->titleFormatter, |
48 | $this->hookContainer, |
49 | $this->userIdentityUtils, |
50 | $this->languageFactory, |
51 | $context |
52 | ); |
53 | } |
54 | |
55 | } |