Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LocalizedNumericSerialMapping
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSerialIdForIndex
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\User\TempUser;
4
5use MediaWiki\Language\Language;
6use MediaWiki\Languages\LanguageFactory;
7
8/**
9 * Serial mapping which uses a Language object to format serial numbers.
10 *
11 * @since 1.39
12 */
13class LocalizedNumericSerialMapping implements SerialMapping {
14    private Language $language;
15
16    /**
17     * @param array $config
18     *   - language: The language code
19     * @param LanguageFactory $languageFactory
20     */
21    public function __construct( $config, LanguageFactory $languageFactory ) {
22        $this->language = $languageFactory->getLanguage( $config['language'] ?? 'en' );
23    }
24
25    public function getSerialIdForIndex( int $index ): string {
26        return $this->language->formatNum( $index );
27    }
28}