ForeignUser.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. // @codeCoverageIgnoreStart
  38. private int $id;
  39. private int $service;
  40. private string $uri;
  41. private ?string $nickname;
  42. private \DateTimeInterface $created;
  43. private \DateTimeInterface $modified;
  44. public function setId(int $id): self
  45. {
  46. $this->id = $id;
  47. return $this;
  48. }
  49. public function getId(): int
  50. {
  51. return $this->id;
  52. }
  53. public function setService(int $service): self
  54. {
  55. $this->service = $service;
  56. return $this;
  57. }
  58. public function getService(): int
  59. {
  60. return $this->service;
  61. }
  62. public function setUri(string $uri): self
  63. {
  64. $this->uri = $uri;
  65. return $this;
  66. }
  67. public function getUri(): string
  68. {
  69. return $this->uri;
  70. }
  71. public function setNickname(?string $nickname): self
  72. {
  73. $this->nickname = $nickname;
  74. return $this;
  75. }
  76. public function getNickname(): ?string
  77. {
  78. return $this->nickname;
  79. }
  80. public function setCreated(DateTimeInterface $created): self
  81. {
  82. $this->created = $created;
  83. return $this;
  84. }
  85. public function getCreated(): DateTimeInterface
  86. {
  87. return $this->created;
  88. }
  89. public function setModified(DateTimeInterface $modified): self
  90. {
  91. $this->modified = $modified;
  92. return $this;
  93. }
  94. public function getModified(): DateTimeInterface
  95. {
  96. return $this->modified;
  97. }
  98. // @codeCoverageIgnoreEnd
  99. // }}} Autocode
  100. public static function schemaDef(): array
  101. {
  102. return [
  103. 'name' => 'foreign_user',
  104. 'fields' => [
  105. 'id' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'],
  106. 'service' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to service'],
  107. 'uri' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'],
  108. 'nickname' => ['type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'],
  109. 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
  110. 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
  111. ],
  112. 'primary key' => ['id', 'service'],
  113. 'foreign keys' => [
  114. 'foreign_user_service_fkey' => ['foreign_service', ['service' => 'id']],
  115. ],
  116. 'unique keys' => [
  117. 'foreign_user_uri_key' => ['uri'],
  118. ],
  119. ];
  120. }
  121. }