Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ZhReplacementMachine
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 2
210
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 isValidCodePair
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
182
1<?php
2
3namespace Wikimedia\LangConv;
4
5class ZhReplacementMachine extends FstReplacementMachine {
6
7    public function __construct() {
8        parent::__construct(
9            'zh',
10            [
11                'zh-hans',
12                'zh-hant',
13                'zh-cn',
14                'zh-hk',
15                'zh-mo',
16                'zh-my',
17                'zh-sg',
18                'zh-tw',
19            ]
20        );
21    }
22
23    /** @inheritDoc */
24    public function isValidCodePair( $destCode, $invertCode ) {
25        if ( $destCode === $invertCode ) {
26            return true;
27        }
28        switch ( $destCode ) {
29            case 'zh-cn':
30                if ( $invertCode === 'zh-tw' ) {
31                    return true;
32                }
33                // fall through
34            case 'zh-sg':
35            case 'zh-my':
36            case 'zh-hans':
37                return $invertCode === 'zh-hant';
38            case 'zh-tw':
39                if ( $invertCode === 'zh-cn' ) {
40                    return true;
41                }
42                // fall through
43            case 'zh-hk':
44            case 'zh-mo':
45            case 'zh-hant':
46                return $invertCode === 'zh-hans';
47            default:
48                return false;
49        }
50    }
51
52}