Passed
Push — develop ( ceecf5...f3db75 )
by BENARD
16:19 queued 14:24
created

Partner::getPartnerStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\PartnerBundle\Entity;
6
7
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
8
use ApiPlatform\Metadata\ApiFilter;
9
use ApiPlatform\Metadata\ApiResource;
10
use ApiPlatform\Metadata\Get;
11
use ApiPlatform\Metadata\GetCollection;
12
use Doctrine\ORM\Mapping as ORM;
13
use ProjetNormandie\PartnerBundle\Repository\PartnerRepository;
14
use ProjetNormandie\PartnerBundle\ValueObject\PartnerStatus;
15
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
16
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
17
use Symfony\Component\Serializer\Attribute\Groups;
18
use Symfony\Component\Validator\Constraints as Assert;
19
20
#[ORM\Table(name:'pnp_partner')]
21
#[ORM\Entity(repositoryClass: PartnerRepository::class)]
22
#[ApiResource(
23
    operations: [
24
        new GetCollection(),
25
        new Get(),
26
    ],
27
    normalizationContext: ['groups' => ['partner:read']]
28
)]
29
#[ApiFilter(
30
    SearchFilter::class,
31
    properties: [
32
        'status' => 'exact',
33
    ]
34
)]
35
class Partner implements TimestampableInterface
36
{
37
    use TimestampableTrait;
38
39
    #[Groups(['partner:read'])]
40
    #[ORM\Id, ORM\Column, ORM\GeneratedValue]
41
    private ?int $id = null;
42
43
    #[Groups(['partner:read'])]
44
    #[ORM\Column(length: 50, nullable: false)]
45
    private string $name;
46
47
    #[Groups(['partner:read'])]
48
    #[ORM\Column(length: 255, nullable: false)]
49
    private string $url;
50
51
    #[Assert\Email]
52
    #[ORM\Column(length: 255, nullable: true)]
53
    private ?string $contact = null;
54
55
    #[ORM\Column(length: 30, nullable: false)]
56
    private string $status = PartnerStatus::INACTIVE;
57
58
    #[ORM\Column(length: 255, nullable: true)]
59
    private ?string $description;
60
61
    #[ORM\Column(length: 255, nullable: true)]
62
    private ?string $comment;
63
64
    public function __toString()
65
    {
66
        return sprintf('Partner [%s]', $this->id);
67
    }
68
69
    public function setId(int $id): void
70
    {
71
        $this->id = $id;
72
    }
73
74
    public function getId(): ?int
75
    {
76
        return $this->id;
77
    }
78
79
    public function setName(string $name): void
80
    {
81
        $this->name = $name;
82
    }
83
84
    public function getName(): string
85
    {
86
        return $this->name;
87
    }
88
89
    public function setUrl(string $url): void
90
    {
91
        $this->url = $url;
92
    }
93
94
    public function getUrl(): string
95
    {
96
        return $this->url;
97
    }
98
99
    public function setContact(string $contact): void
100
    {
101
        $this->contact = $contact;
102
    }
103
104
    public function getContact(): ?string
105
    {
106
        return $this->contact;
107
    }
108
109
    public function setStatus(string $status): void
110
    {
111
        $value = new PartnerStatus($status);
112
        $this->status = $value->getValue();
113
    }
114
115
    public function getStatus(): string
116
    {
117
        return $this->status;
118
    }
119
120
    public function getPartnerStatus(): PartnerStatus
121
    {
122
        return new PartnerStatus($this->status);
123
    }
124
125
    public function setDescription(?string $description): void
126
    {
127
        $this->description = $description;
128
    }
129
130
    public function getDescription(): ?string
131
    {
132
        return $this->description;
133
    }
134
135
    public function setComment(?string $comment): void
136
    {
137
        $this->comment = $comment;
138
    }
139
140
    public function getComment(): ?string
141
    {
142
        return $this->comment;
143
    }
144
}
145