| Total Complexity | 7 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class Storage |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Storage folder type. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected static string $folder; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Skin Path. |
||
| 20 | * |
||
| 21 | * @param string $uuid |
||
| 22 | * |
||
| 23 | * @throws \Exception |
||
| 24 | * |
||
| 25 | * @return string |
||
| 26 | */ |
||
| 27 | public static function getPath(string $uuid): string |
||
| 28 | { |
||
| 29 | if ($uuid === '') { |
||
| 30 | $uuid = MinecraftDefaults::getRandomDefaultSkin(); |
||
| 31 | } |
||
| 32 | |||
| 33 | return \sprintf(storage_path(static::$folder.'/%s.png'), $uuid); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Checks if file exists. |
||
| 38 | * |
||
| 39 | * @param string $uuid |
||
| 40 | * |
||
| 41 | * @return bool |
||
| 42 | */ |
||
| 43 | public static function exists(string $uuid): bool |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Save the skin to file. |
||
| 50 | * |
||
| 51 | * @param string $uuid |
||
| 52 | * @param mixed $rawData |
||
| 53 | * |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | public static function save(string $uuid, $rawData): bool |
||
| 57 | { |
||
| 58 | $fp = \fopen(static::getPath($uuid), 'wb'); |
||
| 59 | if ($fp) { |
||
|
|
|||
| 60 | \fwrite($fp, $rawData); |
||
| 61 | \fclose($fp); |
||
| 62 | |||
| 63 | return true; |
||
| 64 | } |
||
| 65 | |||
| 66 | return false; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Use Steve file for given uuid. |
||
| 71 | * |
||
| 72 | * @param mixed |
||
| 73 | */ |
||
| 74 | public static function copyAsSteve(string $string): bool |
||
| 84 | } |
||
| 85 | } |
||
| 86 |