Advertisement
Kundello

Untitled

Feb 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public function validate($canSetHdSkin)
  2. {
  3. $height = $this->image->getHeight();
  4. $width = $this->image->getWidth();
  5. $ratio = $width / 128;
  6.  
  7. $validHeight = $height / $ratio === 64;
  8. $validWidth = $width / $ratio === 128;
  9.  
  10. if ($canSetHdSkin) {
  11. if ($validHeight && $validWidth && $width <= 1024 && $height <= 512) {
  12. return true;
  13. } else {
  14. throw new InvalidImageSizeException();
  15. }
  16. } else {
  17. if ($validHeight && $validWidth) {
  18. if ($height === 64 && $width === 128) {
  19. return true;
  20. } else {
  21. throw new InvalidImageSizeException();
  22. }
  23. } else {
  24. throw new InvalidImageSizeException();
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement