Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Base64 | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
isEncoded | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
isEncodedImage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace oat\tao\helpers; |
4 | |
5 | /** |
6 | * Class Base64 |
7 | * |
8 | * @package oat\tao\helpers |
9 | */ |
10 | class Base64 |
11 | { |
12 | /** |
13 | * @param $data |
14 | * |
15 | * @return bool |
16 | */ |
17 | public static function isEncoded($data): bool |
18 | { |
19 | return is_string($data) && preg_match('/^data:.*;base64/', $data); |
20 | } |
21 | |
22 | /** |
23 | * @param $data |
24 | * |
25 | * @return bool |
26 | */ |
27 | public static function isEncodedImage($data): bool |
28 | { |
29 | return self::isEncoded($data) && getimagesize($data) !== false; |
30 | } |
31 | } |