Completed
Push — master ( 5117ae...fac286 )
by Joshua
27:26 queued 11:48
created

MappingFileProvider   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 32
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A inMap() 0 4 2
B getFileName() 0 17 7
1
<?php
2
3
namespace libphonenumber\prefixmapper;
4
5
/**
6
 * A utility which knows the data files that are available for the phone prefix mappers to use.
7
 * The data files contain mappings from phone number prefixes to text descriptions, and are
8
 * organized by country calling code and language that the text descriptions are in.
9
 *
10
 * Class MappingFileProvider
11
 * @package libphonenumber\prefixmapper
12
 */
13
class MappingFileProvider
14
{
15
    protected $map;
16
17 253
    public function __construct($map)
18
    {
19 253
        $this->map = $map;
20 253
    }
21
22 25
    public function getFileName($countryCallingCode, $language, $script, $region)
0 ignored issues
show
Unused Code introduced by
The parameter $script is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24 25
        if (strlen($language) == 0) {
25
            return "";
26
        }
27
28 25
        if ($language === 'zh' && ($region == 'TW' || $region == 'HK' || $region == 'MO')) {
29 1
            $language = 'zh_Hant';
30 1
        }
31
32 25
        if ($this->inMap($language, $countryCallingCode)) {
33 20
            return $language . DIRECTORY_SEPARATOR . $countryCallingCode . '.php';
34
        }
35
36
37 9
        return "";
38
    }
39
40 25
    protected function inMap($language, $countryCallingCode)
41
    {
42 25
        return (array_key_exists($language, $this->map) && in_array($countryCallingCode, $this->map[$language]));
43
    }
44
}
45