Passed
Push — main ( f1aa52...bbae52 )
by Karl
06:11
created

Organization::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Entity;
4
5
use ApiPlatform\Metadata\ApiResource;
6
use App\Repository\OrganizationRepository;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\ORM\Mapping as ORM;
10
11
#[ORM\Entity(repositoryClass: OrganizationRepository::class)]
12
#[ApiResource]
13
class Organization
14
{
15
    #[ORM\Id]
16
    #[ORM\GeneratedValue]
17
    #[ORM\Column]
18
    private ?int $id = null;
19
20
    #[ORM\Column(length: 255)]
21
    private ?string $Name = null;
22
23
    /**
24
     * @var Collection<int, User>
25
     */
26
    #[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'organizations')]
27
    private Collection $User;
28
29
    public function __construct()
30
    {
31
        $this->User = new ArrayCollection();
32
    }
33
34
    public function getId(): ?int
35
    {
36
        return $this->id;
37
    }
38
39
    public function getName(): ?string
40
    {
41
        return $this->Name;
42
    }
43
44
    public function setName(string $Name): static
45
    {
46
        $this->Name = $Name;
47
48
        return $this;
49
    }
50
51
    /**
52
     * @return Collection<int, User>
53
     */
54
    public function getUser(): Collection
55
    {
56
        return $this->User;
57
    }
58
59
    public function addUser(User $user): static
60
    {
61
        if (!$this->User->contains($user)) {
62
            $this->User->add($user);
63
        }
64
65
        return $this;
66
    }
67
68
    public function removeUser(User $user): static
69
    {
70
        $this->User->removeElement($user);
71
72
        return $this;
73
    }
74
}
75