Completed
Push — master ( 068196...b73e45 )
by Joshua
42:03 queued 24:35
created

MappingFileProvider   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 92.86%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B getFileName() 0 17 7
A inMap() 0 4 2
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
16
    protected $map;
17
18 252
    public function __construct($map)
19
    {
20 252
        $this->map = $map;
21 252
    }
22
23 27
    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...
24
    {
25 27
        if (strlen($language) == 0) {
26
            return "";
27
        }
28
29 27
        if ($language === 'zh' && ($region == 'TW' || $region == 'HK' || $region == 'MO')) {
30 1
            $language = 'zh_Hant';
31 1
        }
32
33 27
        if ($this->inMap($language, $countryCallingCode)) {
34 22
            return $language . DIRECTORY_SEPARATOR . $countryCallingCode . '.php';
35
        }
36
37
38 9
        return "";
39
    }
40
41 27
    protected function inMap($language, $countryCallingCode)
42
    {
43 27
        return (array_key_exists($language, $this->map) && in_array($countryCallingCode, $this->map[$language]));
44
    }
45
46
}
47