IAvatar.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP;
  28. use OCP\Files\File;
  29. use OCP\Files\NotFoundException;
  30. /**
  31. * This class provides avatar functionality
  32. * @since 6.0.0
  33. */
  34. interface IAvatar {
  35. /**
  36. * get the users avatar
  37. * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image
  38. * @return boolean|\OCP\IImage containing the avatar or false if there's no image
  39. * @since 6.0.0 - size of -1 was added in 9.0.0
  40. */
  41. public function get($size = 64);
  42. /**
  43. * Check if an avatar exists for the user
  44. *
  45. * @return bool
  46. * @since 8.1.0
  47. */
  48. public function exists();
  49. /**
  50. * sets the users avatar
  51. * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar
  52. * @throws \Exception if the provided file is not a jpg or png image
  53. * @throws \Exception if the provided image is not valid
  54. * @throws \OC\NotSquareException if the image is not square
  55. * @return void
  56. * @since 6.0.0
  57. */
  58. public function set($data);
  59. /**
  60. * remove the users avatar
  61. * @return void
  62. * @since 6.0.0
  63. */
  64. public function remove();
  65. /**
  66. * Get the file of the avatar
  67. * @param int $size -1 can be used to not scale the image
  68. * @return File
  69. * @throws NotFoundException
  70. * @since 9.0.0
  71. */
  72. public function getFile($size);
  73. }