Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Invitation | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
13 | |
100.00% |
1 / 1 |
| setCode | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getCode | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| setUserId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getUserId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| setAddress | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getAddress | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| setAddressType | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getAddressType | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| setRegisteredUserId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getRegisteredUserId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| setCreated | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| getCreated | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| schemaDef | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| 1 | <?php |
| 2 | |
| 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 | |
| 20 | namespace App\Entity; |
| 21 | |
| 22 | use App\Core\Entity; |
| 23 | use DateTimeInterface; |
| 24 | |
| 25 | /** |
| 26 | * Entity for user invitations |
| 27 | * |
| 28 | * @category DB |
| 29 | * @package GNUsocial |
| 30 | * |
| 31 | * @author Zach Copley <zach@status.net> |
| 32 | * @copyright 2010 StatusNet Inc. |
| 33 | * @author Mikael Nordfeldth <mmn@hethane.se> |
| 34 | * @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org |
| 35 | * @author Hugo Sales <hugo@hsal.es> |
| 36 | * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org |
| 37 | * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later |
| 38 | */ |
| 39 | class Invitation extends Entity |
| 40 | { |
| 41 | // {{{ Autocode |
| 42 | // @codeCoverageIgnoreStart |
| 43 | private string $code; |
| 44 | private int $user_id; |
| 45 | private string $address; |
| 46 | private string $address_type; |
| 47 | private ?int $registered_user_id; |
| 48 | private \DateTimeInterface $created; |
| 49 | |
| 50 | public function setCode(string $code): self |
| 51 | { |
| 52 | $this->code = $code; |
| 53 | return $this; |
| 54 | } |
| 55 | |
| 56 | public function getCode(): string |
| 57 | { |
| 58 | return $this->code; |
| 59 | } |
| 60 | |
| 61 | public function setUserId(int $user_id): self |
| 62 | { |
| 63 | $this->user_id = $user_id; |
| 64 | return $this; |
| 65 | } |
| 66 | |
| 67 | public function getUserId(): int |
| 68 | { |
| 69 | return $this->user_id; |
| 70 | } |
| 71 | |
| 72 | public function setAddress(string $address): self |
| 73 | { |
| 74 | $this->address = $address; |
| 75 | return $this; |
| 76 | } |
| 77 | |
| 78 | public function getAddress(): string |
| 79 | { |
| 80 | return $this->address; |
| 81 | } |
| 82 | |
| 83 | public function setAddressType(string $address_type): self |
| 84 | { |
| 85 | $this->address_type = $address_type; |
| 86 | return $this; |
| 87 | } |
| 88 | |
| 89 | public function getAddressType(): string |
| 90 | { |
| 91 | return $this->address_type; |
| 92 | } |
| 93 | |
| 94 | public function setRegisteredUserId(?int $registered_user_id): self |
| 95 | { |
| 96 | $this->registered_user_id = $registered_user_id; |
| 97 | return $this; |
| 98 | } |
| 99 | |
| 100 | public function getRegisteredUserId(): ?int |
| 101 | { |
| 102 | return $this->registered_user_id; |
| 103 | } |
| 104 | |
| 105 | public function setCreated(DateTimeInterface $created): self |
| 106 | { |
| 107 | $this->created = $created; |
| 108 | return $this; |
| 109 | } |
| 110 | |
| 111 | public function getCreated(): DateTimeInterface |
| 112 | { |
| 113 | return $this->created; |
| 114 | } |
| 115 | |
| 116 | // @codeCoverageIgnoreEnd |
| 117 | // }}} Autocode |
| 118 | |
| 119 | public static function schemaDef(): array |
| 120 | { |
| 121 | return [ |
| 122 | 'name' => 'invitation', |
| 123 | 'fields' => [ |
| 124 | 'code' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'random code for an invitation'], |
| 125 | 'user_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'many to one', 'name' => 'invitation_user_id_fkey', 'not null' => true, 'description' => 'who sent the invitation'], |
| 126 | 'address' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'invitation sent to'], |
| 127 | 'address_type' => ['type' => 'varchar', 'length' => 8, 'not null' => true, 'description' => 'address type ("email", "xmpp", "sms")'], |
| 128 | 'registered_user_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'name' => 'invitation_registered_user_id_fkey', 'type' => 'int', 'not null' => false, 'description' => 'if the invitation is converted, who the new user is'], |
| 129 | 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], |
| 130 | ], |
| 131 | 'primary key' => ['code'], |
| 132 | 'indexes' => [ |
| 133 | 'invitation_address_idx' => ['address', 'address_type'], |
| 134 | 'invitation_user_id_idx' => ['user_id'], |
| 135 | 'invitation_registered_user_id_idx' => ['registered_user_id'], |
| 136 | ], |
| 137 | ]; |
| 138 | } |
| 139 | } |