Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Digit2Html
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 2
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2/**
3 * Check digit transformation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup MaintenanceLanguage
22 */
23
24require_once __DIR__ . '/../Maintenance.php';
25
26/**
27 * Maintenance script that check digit transformation.
28 *
29 * @ingroup MaintenanceLanguage
30 */
31class Digit2Html extends Maintenance {
32
33    /**
34     * @var string[] A list of unicode numerals is available at:
35     * https://www.fileformat.info/info/unicode/category/Nd/list.htm
36     */
37    private $mLangs = [
38        'Ar', 'As', 'Bh', 'Bo', 'Dz',
39        'Fa', 'Gu', 'Hi', 'Km', 'Kn',
40        'Ks', 'Lo', 'Ml', 'Mr', 'Ne',
41        'New', 'Or', 'Pa', 'Pi', 'Sa'
42    ];
43
44    public function __construct() {
45        parent::__construct();
46        $this->addDescription( 'Check digit transformation' );
47    }
48
49    public function execute() {
50        $languageNameUtils = $this->getServiceContainer()->getLanguageNameUtils();
51        foreach ( $this->mLangs as $code ) {
52            $filename = $languageNameUtils->getMessagesFileName( $code );
53            $this->output( "Loading language [$code] ..." );
54            unset( $digitTransformTable );
55            require_once $filename;
56            if ( !isset( $digitTransformTable ) ) {
57                $this->error( "\$digitTransformTable not found for lang: $code" );
58                continue;
59            }
60
61            $this->output( "OK\n\$digitTransformTable = [\n" );
62            foreach ( $digitTransformTable as $latin => $translation ) {
63                $htmlent = bin2hex( $translation );
64                $this->output( "'$latin' => '$translation', # &#x$htmlent;\n" );
65            }
66            $this->output( "];\n" );
67        }
68    }
69}
70
71$maintClass = Digit2Html::class;
72require_once RUN_MAINTENANCE_IF_MAIN;