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

MappingFileProvider::getFileName()   B

Complexity

Conditions 7
Paths 5

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 7.0957

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 17
ccs 7
cts 8
cp 0.875
rs 8.2222
cc 7
eloc 8
nc 5
nop 4
crap 7.0957
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