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