ForeignService.php 3.6 KB

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