ForeignUser.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. // {{{ License
  3. // This file is part of GNU social - https://www.gnu.org/software/social
  4. //
  5. // GNU social is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Affero General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // GNU social is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Affero General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  17. // }}}
  18. namespace Component\Bridge\Entity;
  19. use DateTimeInterface;
  20. /**
  21. * Entity for Foreign Users
  22. *
  23. * @category DB
  24. * @package GNUsocial
  25. *
  26. * @author Zach Copley <zach@status.net>
  27. * @copyright 2010 StatusNet Inc.
  28. * @author Mikael Nordfeldth <mmn@hethane.se>
  29. * @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
  30. * @author Hugo Sales <hugo@hsal.es>
  31. * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
  32. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  33. */
  34. class ForeignUser
  35. {
  36. // {{{ Autocode
  37. private int $id;
  38. private int $service;
  39. private string $uri;
  40. private ?string $nickname;
  41. private DateTimeInterface $created;
  42. private DateTimeInterface $modified;
  43. public function setId(int $id): self
  44. {
  45. $this->id = $id;
  46. return $this;
  47. }
  48. public function getId(): int
  49. {
  50. return $this->id;
  51. }
  52. public function setService(int $service): self
  53. {
  54. $this->service = $service;
  55. return $this;
  56. }
  57. public function getService(): int
  58. {
  59. return $this->service;
  60. }
  61. public function setUri(string $uri): self
  62. {
  63. $this->uri = $uri;
  64. return $this;
  65. }
  66. public function getUri(): string
  67. {
  68. return $this->uri;
  69. }
  70. public function setNickname(?string $nickname): self
  71. {
  72. $this->nickname = $nickname;
  73. return $this;
  74. }
  75. public function getNickname(): ?string
  76. {
  77. return $this->nickname;
  78. }
  79. public function setCreated(DateTimeInterface $created): self
  80. {
  81. $this->created = $created;
  82. return $this;
  83. }
  84. public function getCreated(): DateTimeInterface
  85. {
  86. return $this->created;
  87. }
  88. public function setModified(DateTimeInterface $modified): self
  89. {
  90. $this->modified = $modified;
  91. return $this;
  92. }
  93. public function getModified(): DateTimeInterface
  94. {
  95. return $this->modified;
  96. }
  97. // }}} Autocode
  98. public static function schemaDef(): array
  99. {
  100. return [
  101. 'name' => 'foreign_user',
  102. 'fields' => [
  103. 'id' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'],
  104. 'service' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to service'],
  105. 'uri' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'],
  106. 'nickname' => ['type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'],
  107. 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
  108. 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
  109. ],
  110. 'primary key' => ['id', 'service'],
  111. 'foreign keys' => [
  112. 'foreign_user_service_fkey' => ['foreign_service', ['service' => 'id']],
  113. ],
  114. 'unique keys' => [
  115. 'foreign_user_uri_key' => ['uri'],
  116. ],
  117. ];
  118. }
  119. }