Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
60.00% covered (warning)
60.00%
6 / 10
55.56% covered (warning)
55.56%
5 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
Category
60.00% covered (warning)
60.00%
6 / 10
55.56% covered (warning)
55.56%
5 / 9
14.18
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 __toString
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSysteme
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setSysteme
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDocuments
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDocuments
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
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\Documentation\Model;
25
26use App\Application\Traits\Model\CreatorTrait;
27use App\Application\Traits\Model\HistoryTrait;
28use Doctrine\Common\Collections\ArrayCollection;
29use Doctrine\Common\Collections\Collection;
30use Doctrine\ORM\Mapping as ORM;
31use Ramsey\Uuid\Uuid;
32use Ramsey\Uuid\UuidInterface;
33
34#[ORM\Entity]
35class Category
36{
37    use HistoryTrait;
38    use CreatorTrait;
39
40    #[ORM\Id()]
41    #[ORM\Column(type: 'uuid')]
42    private UuidInterface $id;
43
44    #[ORM\Column(type: 'string')]
45    private ?string $name;
46
47    #[ORM\Column(type: 'boolean')]
48    private ?bool $systeme;
49
50    #[ORM\ManyToMany(targetEntity: 'Document', inversedBy: 'categories')]
51    #[ORM\JoinTable(name: 'document_categories')]
52    #[ORM\JoinColumn(name: 'document_id', referencedColumnName: 'id', onDelete: 'cascade')]
53    #[ORM\InverseJoinColumn(name: 'category_id', referencedColumnName: 'id', onDelete: 'cascade')]
54    private array|Collection|null $documents;
55
56    /**
57     * Category constructor.
58     *
59     * @throws \Exception
60     */
61    public function __construct()
62    {
63        $this->id        = Uuid::uuid4();
64        $this->documents = new ArrayCollection();
65    }
66
67    public function __toString(): string
68    {
69        return $this->getName() ?? '';
70    }
71
72    public function getId(): UuidInterface
73    {
74        return $this->id;
75    }
76
77    public function getName(): ?string
78    {
79        return $this->name;
80    }
81
82    public function setName(?string $name): void
83    {
84        $this->name = $name;
85    }
86
87    public function getSysteme(): ?bool
88    {
89        return $this->systeme;
90    }
91
92    public function setSysteme(?bool $systeme): void
93    {
94        $this->systeme = $systeme;
95    }
96
97    public function getDocuments(): ?iterable
98    {
99        return $this->documents;
100    }
101
102    public function setDocuments(?array $documents): void
103    {
104        $this->documents = $documents;
105    }
106}