Completed
Push — analysis-z4wVAw ( 7f865f )
by Joshua
21:35 queued 05:10
created

MappingFileProvider::inMap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 2
ccs 2
cts 2
cp 1
crap 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