-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountry.php
112 lines (94 loc) · 2.35 KB
/
Country.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
declare(strict_types=1);
namespace Tamedevelopers\Support;
use Tamedevelopers\Support\Str;
use Tamedevelopers\Support\Traits\CountryTrait;
class Country {
use CountryTrait;
/**
* Get Country ISO 3
* @param string|null $mode
* @return string|null
*/
static public function getCountryIso3($mode = null)
{
return self::countryIso3()[self::mode($mode)] ?? null;
}
/**
* Get Country ISO 2
* @param string|null $mode
* @return string|null
*/
static public function getCountryIso2($mode = null)
{
return self::countryIso2()[self::mode($mode)] ?? null;
}
/**
* Get Country Flags for ISO 3
* @param string|null $mode
* @return string|null
*/
static public function getCountryFlagIso3($mode = null)
{
return self::countryFlagIso3()[self::mode($mode)] ?? null;
}
/**
* Get Country Flags for ISO 2
* @param string|null $mode
* @return string|null
*/
static public function getCountryFlagIso2($mode = null)
{
return self::countryFlagIso2()[self::mode($mode)] ?? null;
}
/**
* Get Months Data
*
* @return string|null
*/
static public function getMonths($mode = null)
{
return self::months()[$mode] ?? null;
}
/**
* Get Week
* @param string|null $mode
* @return string|null
*/
static public function getWeeks($mode = null)
{
return self::weeks()[$mode] ?? null;
}
/**
* Get Time Zones
*
* @param string|null $mode
* @param string|null $default
*
* @return string|null
*/
static public function getTimeZone($mode = null, ?string $default = 'UTC')
{
$data = self::timeZone();
// check if mode is numeric
if(is_numeric($mode)){
return $data[(int) $mode] ?? $default;
}
// flip array to get position num
$flip = array_flip($data);
return $data[$flip[$mode] ?? null] ?? $default;
}
/**
* Get Captcha Locale
* @param string|null $mode
*
* @return string|null
*/
static public function getCaptchaLocale($mode = null)
{
$data = self::captchaLocale();
return $data[$mode]
?? array_flip($data)[$mode]
?? null;
}
}