Total Complexity | 7 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class Storage |
||
10 | { |
||
11 | /** |
||
12 | * Storage folder type. |
||
13 | */ |
||
14 | protected static string $folder; |
||
15 | |||
16 | public static function getPath(string $uuid): string |
||
17 | { |
||
18 | if ($uuid === '') { |
||
19 | $uuid = MinecraftDefaults::getRandomDefaultSkin(); |
||
20 | } |
||
21 | |||
22 | return sprintf(storage_path(static::$folder.'/%s.png'), $uuid); |
||
23 | } |
||
24 | |||
25 | public static function exists(string $uuid): bool |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Save the skin to file. |
||
32 | * |
||
33 | * @param mixed $rawData |
||
34 | */ |
||
35 | public static function save(string $uuid, $rawData): bool |
||
36 | { |
||
37 | $fp = fopen(static::getPath($uuid), 'wb'); |
||
38 | if (\is_resource($fp)) { |
||
39 | fwrite($fp, $rawData); |
||
40 | fclose($fp); |
||
41 | |||
42 | return true; |
||
43 | } |
||
44 | |||
45 | return false; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Use Steve file for given uuid. |
||
50 | */ |
||
51 | public static function copyAsSteve(string $name): bool |
||
61 | } |
||
62 | } |
||
63 |