Completed
Push — analysis-z4wVAw ( 7f865f )
by Joshua
21:35 queued 05:10
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.31%

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 10
c 4
b 2
f 0
lcom 1
cbo 0
dl 0
loc 32
rs 10
ccs 12
cts 13
cp 0.9231

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