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