Skip to content

Commit aee905c

Browse files
committed
Refactoring path-sized methods
1 parent f878591 commit aee905c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Utils/Texture.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public static function STORAGE_DIR(): string
5151
* ResponseTypeEnum::CAPE_RESIZE|
5252
* TextureStorageTypeEnum::MOJANG|TextureStorageTypeEnum::COLLECTION $type
5353
*/
54-
public static function TEXTURE_STORAGE_DIR(ResponseTypeEnum|TextureStorageTypeEnum $type): string
54+
public static function TEXTURE_STORAGE_TYPE_DIR(ResponseTypeEnum|TextureStorageTypeEnum $type): string
5555
{
5656
return match ($type) {
5757
ResponseTypeEnum::SKIN, ResponseTypeEnum::CAPE, ResponseTypeEnum::AVATAR,
5858
ResponseTypeEnum::FRONT, ResponseTypeEnum::FRONT_CAPE, ResponseTypeEnum::FRONT_WITH_CAPE,
5959
ResponseTypeEnum::BACK, ResponseTypeEnum::BACK_CAPE, ResponseTypeEnum::BACK_WITH_CAPE,
6060
ResponseTypeEnum::CAPE_RESIZE => self::STORAGE_DIR() . ar_slash_string(getenv()['TEXTURE_' . $type->name . '_PATH'] ?? (strtolower($type->name) . 's')),
6161
TextureStorageTypeEnum::MOJANG, TextureStorageTypeEnum::COLLECTION => self::STORAGE_DIR() . ar_slash_string(getenv()['TEXTURE_' . $type->name . '_PATH'] ?? $type->name),
62-
default => throw new \InvalidArgumentException(sprintf('Un-supported TEXTURE_STORAGE_DIR: %s', $type->name))
62+
default => throw new \InvalidArgumentException(sprintf('Un-supported TEXTURE_STORAGE_TYPE_DIR: %s', $type->name))
6363
};
6464
}
6565
public static function EXTENSTION(): string
@@ -74,16 +74,16 @@ public static function EXTENSTION(): string
7474
* ResponseTypeEnum::CAPE_RESIZE|
7575
* TextureStorageTypeEnum::MOJANG|TextureStorageTypeEnum::COLLECTION $type
7676
*/
77-
public static function TEXTURE_STORAGE_FULL_PATH(ResponseTypeEnum|TextureStorageTypeEnum $type): string
77+
public static function TEXTURE_STORAGE_FULL_PATH(ResponseTypeEnum|TextureStorageTypeEnum $type, ?int $size = null): string
7878
{
79-
return Path::ROOT_FOLDER() . self::TEXTURE_STORAGE_DIR($type);
79+
$size = null === $size ? '' : str_ends_with_slash((string) $size);
80+
return Path::ROOT_FOLDER() . self::TEXTURE_STORAGE_TYPE_DIR($type) . $size;
8081
}
8182
/** FOR PHP ONLY */
8283
public static function PATH(ResponseTypeEnum|TextureStorageTypeEnum $type, string $login, ?string $extension = null, ?int $size = null): string
8384
{
8485
$extension ??= self::EXTENSTION();
85-
$size = null === $size ? '' : str_ends_with_slash((string) $size);
86-
return self::TEXTURE_STORAGE_FULL_PATH($type) . $size . $login . $extension;
86+
return self::TEXTURE_STORAGE_FULL_PATH($type, $size) . $login . $extension;
8787
}
8888
/** @return array<array{w: int, h: int}> */
8989
public static function SIZE(ResponseTypeEnum $type = ResponseTypeEnum::SKIN): array

0 commit comments

Comments
 (0)