Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
17.65% covered (danger)
17.65%
3 / 17
37.50% covered (danger)
37.50%
3 / 8
CRAP
0.00% covered (danger)
0.00%
0 / 1
ComiteIlContact
17.65% covered (danger)
17.65%
3 / 17
37.50% covered (danger)
37.50%
3 / 8
54.24
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getContact
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setContact
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCollectivity
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCollectivity
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 __toString
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3/**
4 * This file is part of the MADIS - RGPD Management application.
5 *
6 * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22declare(strict_types=1);
23
24namespace App\Domain\User\Model;
25
26use App\Domain\Reporting\Model\LoggableSubject;
27use App\Domain\User\Model\Embeddable\Contact;
28use Ramsey\Uuid\Uuid;
29use Ramsey\Uuid\UuidInterface;
30
31class ComiteIlContact implements LoggableSubject, \JsonSerializable
32{
33    /**
34     * @var UuidInterface
35     */
36    private $id;
37
38    /**
39     * @var Contact|null
40     */
41    private $contact;
42
43    /**
44     * @var Collectivity
45     */
46    private $collectivity;
47
48    public function __construct()
49    {
50        $this->id = Uuid::uuid4();
51    }
52
53    public function getId(): UuidInterface
54    {
55        return $this->id;
56    }
57
58    public function getContact(): ?Contact
59    {
60        return $this->contact;
61    }
62
63    public function setContact(?Contact $contact): void
64    {
65        $this->contact = $contact;
66    }
67
68    public function getCollectivity(): Collectivity
69    {
70        return $this->collectivity;
71    }
72
73    public function setCollectivity(Collectivity $collectivity): void
74    {
75        $this->collectivity = $collectivity;
76    }
77
78    public function jsonSerialize(): array
79    {
80        $contact = $this->getContact();
81
82        return [
83            'civilite' => $contact->getCivility(),
84            'prénom'   => $contact->getFirstName(),
85            'nom'      => $contact->getLastName(),
86            'fonction' => $contact->getJob(),
87            'email'    => $contact->getMail(),
88            'tel'      => $contact->getPhoneNumber(),
89        ];
90    }
91
92    public function __toString(): string
93    {
94        $contact = $this->getContact();
95
96        return !\is_null($contact) ? $contact->getLastName() . ' ' . $contact->getFirstName() : '';
97    }
98}