Passed
Push — main ( b87b9b...32046f )
by Axel
04:33
created

Group::getNbumax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\GroupsBundle\Entity;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\Common\Collections\Collection;
18
use Doctrine\DBAL\Types\Types;
19
use Doctrine\ORM\Mapping as ORM;
20
use Symfony\Component\Validator\Constraints as Assert;
21
use Zikula\GroupsBundle\Repository\GroupRepository;
22
use Zikula\UsersBundle\Entity\User;
23
24
#[ORM\Entity(repositoryClass: GroupRepository::class)]
25
#[ORM\Table(name: 'groups_group')]
26
class Group
27
{
28
    #[ORM\Id]
29
    #[ORM\Column]
30
    #[ORM\GeneratedValue(strategy: 'AUTO')]
31
    private int $gid;
32
33
    #[ORM\Column(length: 190, unique: true)]
34
    #[Assert\Length(min: 1, max: 190)]
35
    private string $name;
36
37
    #[ORM\Column(type: Types::SMALLINT)]
38
    private int $gtype;
39
40
    #[ORM\Column(length: 200)]
41
    #[Assert\Length(min: 1, max: 200)]
42
    private string $description;
43
44
    #[ORM\Column(type: Types::SMALLINT)]
45
    private int $state;
46
47
    // maximum membership count
48
    #[ORM\Column]
49
    private int $nbumax;
50
51
    #[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'groups', indexBy: 'uid')]
52
    #[ORM\JoinTable(name: 'group_membership')]
53
    #[ORM\JoinColumn(name: 'gid', referencedColumnName: 'gid', onDelete: 'CASCADE')]
54
    #[ORM\InverseJoinColumn(name: 'uid', referencedColumnName: 'uid')]
55
    #[ORM\OrderBy(['uname' => 'ASC'])]
56
    /** @var User[] $users */
57
    private Collection $users;
58
59
    public function __construct()
60
    {
61
        $this->name = '';
62
        $this->gtype = 0;
63
        $this->description = '';
64
        $this->state = 0;
65
        $this->nbumax = 0;
66
        $this->users = new ArrayCollection();
67
    }
68
69
    public function getGid(): ?int
70
    {
71
        return $this->gid;
72
    }
73
74
    public function setGid(int $gid): self
75
    {
76
        $this->gid = $gid;
77
78
        return $this;
79
    }
80
81
    public function getName(): string
82
    {
83
        return $this->name;
84
    }
85
86
    public function setName(string $name): self
87
    {
88
        $this->name = $name;
89
90
        return $this;
91
    }
92
93
    public function getGtype(): int
94
    {
95
        return $this->gtype;
96
    }
97
98
    public function setGtype(int $gtype): self
99
    {
100
        $this->gtype = $gtype;
101
102
        return $this;
103
    }
104
105
    public function getDescription(): string
106
    {
107
        return $this->description;
108
    }
109
110
    public function setDescription(string $description): self
111
    {
112
        $this->description = $description;
113
114
        return $this;
115
    }
116
117
    public function getState(): int
118
    {
119
        return $this->state;
120
    }
121
122
    public function setState(int $state): self
123
    {
124
        $this->state = $state;
125
126
        return $this;
127
    }
128
129
    public function getNbumax(): int
130
    {
131
        return $this->nbumax;
132
    }
133
134
    public function setNbumax(int $nbumax): self
135
    {
136
        $this->nbumax = $nbumax;
137
138
        return $this;
139
    }
140
141
    public function getUsers(): Collection
142
    {
143
        return $this->users;
144
    }
145
146
    public function addUser(User $user): self
147
    {
148
        $this->users[] = $user;
149
150
        return $this;
151
    }
152
153
    public function removeUser(User $user): self
154
    {
155
        $this->users->removeElement($user);
156
157
        return $this;
158
    }
159
160
    public function removeAllUsers(): self
161
    {
162
        $this->users->clear();
163
164
        return $this;
165
    }
166
}
167