Country::isValidCountry()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
ccs 3
cts 3
cp 1
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
/*
3
 * Copyright 2016 Jan Eichhorn <[email protected]>
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace ApaiIO\Configuration;
19
20
/**
21
 * Countryvalidation and countrylistings according to the amazonapi
22
 *
23
 * @author Jan Eichhorn <[email protected]>
24
 */
25
final class Country
26
{
27
    /**
28
     * Possible countries
29
     * Important for the requestendpoints
30
     *
31
     * @var array
32
     */
33
    private static $countryList = [
34
        'de',
35
        'com',
36
        'co.uk',
37
        'ca',
38
        'fr',
39
        'co.jp',
40
        'it',
41
        'cn',
42
        'es',
43
        'in',
44
        'com.br',
45
        'com.mx',
46
        'com.au'
47
    ];
48
49
    /**
50
     * Gets all possible countries
51
     *
52
     * @return array
53
     */
54 2
    public static function getCountries()
55
    {
56 2
        return self::$countryList;
57
    }
58
59
    /**
60
     * Checks if the given value is a valid country
61
     *
62
     * @param string  $country
63
     *
64
     * @return boolean
65
     */
66 6
    public static function isValidCountry($country)
67
    {
68 6
        $isValid = in_array(strtolower($country), self::$countryList) ? true : false;
69
70 6
        return $isValid;
71
    }
72
}
73