Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Charset | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
getPhpCharsets | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isValid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace pvc\intl; |
6 | |
7 | use pvc\interfaces\intl\CharsetInterface; |
8 | |
9 | class Charset implements CharsetInterface |
10 | { |
11 | /** |
12 | * getPhpCharsets |
13 | * @return array<int, string> |
14 | */ |
15 | public static function getPhpCharsets(): array |
16 | { |
17 | return mb_list_encodings(); |
18 | } |
19 | |
20 | /** |
21 | * isValid |
22 | * @param string $charset |
23 | * @return bool |
24 | */ |
25 | public static function isValid(string $charset): bool |
26 | { |
27 | return in_array($charset, self::getPhpCharsets()); |
28 | } |
29 | } |