Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
2 / 2 |
LocalGroup | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
10 | |
100.00% |
2 / 2 |
setGroupId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getGroupId | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
setNickname | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getNickname | 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 |
|||||
setModified | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getModified | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
getActor | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
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/soci |
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 publ |
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 Li |
17 | // along with GNU social. If not, see <http://www.gnu.org/licenses/>. |
18 | // }}} |
19 | |
20 | namespace App\Entity; |
21 | |
22 | use App\Core\DB\DB; |
23 | use App\Core\Entity; |
24 | |
25 | use DateTimeInterface; |
26 | |
27 | /** |
28 | * Entity for local groups |
29 | * |
30 | * @category DB |
31 | * @package GNUsocial |
32 | * |
33 | * @author Zach Copley <zach@status.net> |
34 | * @copyright 2010 StatusNet Inc. |
35 | * @author Mikael Nordfeldth <mmn@hethane.se> |
36 | * @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org |
37 | * @author Hugo Sales <hugo@hsal.es> |
38 | * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org |
39 | * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later |
40 | */ |
41 | class LocalGroup extends Entity |
42 | { |
43 | // {{{ Autocode |
44 | // @codeCoverageIgnoreStart |
45 | private int $group_id; |
46 | private ?string $nickname; |
47 | private \DateTimeInterface $created; |
48 | private \DateTimeInterface $modified; |
49 | |
50 | public function setGroupId(int $group_id): self |
51 | { |
52 | $this->group_id = $group_id; |
53 | return $this; |
54 | } |
55 | |
56 | public function getGroupId(): int |
57 | { |
58 | return $this->group_id; |
59 | } |
60 | |
61 | public function setNickname(?string $nickname): self |
62 | { |
63 | $this->nickname = $nickname; |
64 | return $this; |
65 | } |
66 | |
67 | public function getNickname(): ?string |
68 | { |
69 | return $this->nickname; |
70 | } |
71 | |
72 | public function setCreated(DateTimeInterface $created): self |
73 | { |
74 | $this->created = $created; |
75 | return $this; |
76 | } |
77 | |
78 | public function getCreated(): DateTimeInterface |
79 | { |
80 | return $this->created; |
81 | } |
82 | |
83 | public function setModified(DateTimeInterface $modified): self |
84 | { |
85 | $this->modified = $modified; |
86 | return $this; |
87 | } |
88 | |
89 | public function getModified(): DateTimeInterface |
90 | { |
91 | return $this->modified; |
92 | } |
93 | |
94 | // @codeCoverageIgnoreEnd |
95 | // }}} Autocode |
96 | |
97 | public function getActor() |
98 | { |
99 | return DB::find('gsactor', ['id' => $this->group_id]); |
100 | } |
101 | |
102 | public static function schemaDef(): array |
103 | { |
104 | return [ |
105 | 'name' => 'local_group', |
106 | 'description' => 'Record for a user group on the local site, with some additional info not in user_group', |
107 | 'fields' => [ |
108 | 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'one to one', 'name' => 'local_group_group_id_fkey', 'not null' => true, 'description' => 'group represented'], |
109 | 'nickname' => ['type' => 'varchar', 'length' => 64, 'description' => 'group represented'], |
110 | 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], |
111 | 'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], |
112 | ], |
113 | 'primary key' => ['group_id'], |
114 | 'unique keys' => [ |
115 | 'local_group_nickname_key' => ['nickname'], |
116 | ], |
117 | ]; |
118 | } |
119 | } |