User.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Remote;
  7. use OCP\Remote\IUser;
  8. class User implements IUser {
  9. public const EXPECTED_KEYS = [
  10. 'id',
  11. 'email',
  12. 'displayname',
  13. 'phone',
  14. 'address',
  15. 'website',
  16. 'groups',
  17. 'language',
  18. 'quota'
  19. ];
  20. /** @var array */
  21. private $data;
  22. public function __construct(array $data) {
  23. $this->data = $data;
  24. }
  25. /**
  26. * @return string
  27. */
  28. public function getUserId() {
  29. return $this->data['id'];
  30. }
  31. /**
  32. * @return string
  33. */
  34. public function getEmail() {
  35. return $this->data['email'];
  36. }
  37. /**
  38. * @return string
  39. */
  40. public function getDisplayName() {
  41. return $this->data['displayname'];
  42. }
  43. /**
  44. * @return string
  45. */
  46. public function getPhone() {
  47. return $this->data['phone'];
  48. }
  49. /**
  50. * @return string
  51. */
  52. public function getAddress() {
  53. return $this->data['address'];
  54. }
  55. /**
  56. * @return string
  57. */
  58. public function getWebsite() {
  59. return $this->data['website'];
  60. }
  61. /**
  62. * @return string
  63. */
  64. public function getTwitter() {
  65. return $this->data['twitter'] ?? '';
  66. }
  67. /**
  68. * @return string[]
  69. */
  70. public function getGroups() {
  71. return $this->data['groups'];
  72. }
  73. /**
  74. * @return string
  75. */
  76. public function getLanguage() {
  77. return $this->data['language'];
  78. }
  79. /**
  80. * @return int
  81. */
  82. public function getUsedSpace() {
  83. return $this->data['quota']['used'];
  84. }
  85. /**
  86. * @return int
  87. */
  88. public function getFreeSpace() {
  89. return $this->data['quota']['free'];
  90. }
  91. /**
  92. * @return int
  93. */
  94. public function getTotalSpace() {
  95. return $this->data['quota']['total'];
  96. }
  97. /**
  98. * @return int
  99. */
  100. public function getQuota() {
  101. return $this->data['quota']['quota'];
  102. }
  103. }