1
0

User.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace OC\Remote;
  22. use OCP\Remote\IUser;
  23. class User implements IUser {
  24. const EXPECTED_KEYS = [
  25. 'id',
  26. 'email',
  27. 'displayname',
  28. 'phone',
  29. 'address',
  30. 'website',
  31. 'groups',
  32. 'language',
  33. 'quota'
  34. ];
  35. /** @var array */
  36. private $data;
  37. public function __construct(array $data) {
  38. $this->data = $data;
  39. }
  40. /**
  41. * @return string
  42. */
  43. public function getUserId() {
  44. return $this->data['id'];
  45. }
  46. /**
  47. * @return string
  48. */
  49. public function getEmail() {
  50. return $this->data['email'];
  51. }
  52. /**
  53. * @return string
  54. */
  55. public function getDisplayName() {
  56. return $this->data['displayname'];
  57. }
  58. /**
  59. * @return string
  60. */
  61. public function getPhone() {
  62. return $this->data['phone'];
  63. }
  64. /**
  65. * @return string
  66. */
  67. public function getAddress() {
  68. return $this->data['address'];
  69. }
  70. /**
  71. * @return string
  72. */
  73. public function getWebsite() {
  74. return $this->data['website'];
  75. }
  76. /**
  77. * @return string
  78. */
  79. public function getTwitter() {
  80. return isset($this->data['twitter']) ? $this->data['twitter'] : '';
  81. }
  82. /**
  83. * @return string[]
  84. */
  85. public function getGroups() {
  86. return $this->data['groups'];
  87. }
  88. /**
  89. * @return string
  90. */
  91. public function getLanguage() {
  92. return $this->data['language'];
  93. }
  94. /**
  95. * @return int
  96. */
  97. public function getUsedSpace() {
  98. return $this->data['quota']['used'];
  99. }
  100. /**
  101. * @return int
  102. */
  103. public function getFreeSpace() {
  104. return $this->data['quota']['free'];
  105. }
  106. /**
  107. * @return int
  108. */
  109. public function getTotalSpace() {
  110. return $this->data['quota']['total'];
  111. }
  112. /**
  113. * @return int
  114. */
  115. public function getQuota() {
  116. return $this->data['quota']['quota'];
  117. }
  118. }