Created
January 21, 2024 07:57
-
-
Save emmadesilva/ca4e8f79fa36481d6b49ca8af5a44b22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum ImageSizes: string { | |
| case Square = '768x768'; | |
| case Portrait = '512x768'; | |
| case Landscape = '768x512'; | |
| /** @return array{width: int, height: int} */ | |
| public function toArray(): array { | |
| $size = explode('x', $this->value); | |
| return [ | |
| 'width' => (int) $size[0], | |
| 'height' => (int) $size[1], | |
| ]; | |
| } | |
| public function height(): int { | |
| return $this->toArray()['height']; | |
| } | |
| public function width(): int { | |
| return $this->toArray()['width']; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment