Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
50.00% covered (danger)
50.00%
10 / 20
55.56% covered (warning)
55.56%
5 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
Textauswahlgruppe
50.00% covered (danger)
50.00%
10 / 20
55.56% covered (warning)
55.56%
5 / 9
34.12
0.00% covered (danger)
0.00%
0 / 1
 __construct
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
 addKind
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 getKinder
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLfdnr
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getVater
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setVater
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 removeKind
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3declare(strict_types=1);
4
5namespace Satag\AmicronEntityBundle\Entity;
6
7use Doctrine\Common\Collections\ArrayCollection;
8use Doctrine\Common\Collections\Collection;
9use Doctrine\DBAL\Types\Types;
10use Doctrine\ORM\Mapping as ORM;
11
12/**
13 * @see \Satag\AmicronEntityBundle\Tests\Entity\TextauswahlgruppeTest
14 */
15#[ORM\Entity]
16#[ORM\Table(name: 'TBGRUP')]
17#[ORM\Index(columns: ['vaterlfdnr'], name: 'TBGRUP_VATERLFDNR_FK')]
18class Textauswahlgruppe
19{
20    /**
21     * @var Collection<int, Textauswahlgruppe>
22     */
23    #[ORM\OneToMany(mappedBy: 'vater', targetEntity: Textauswahlgruppe::class, cascade: ['persist'])]
24    private Collection $kinder;
25
26    #[ORM\Column(name: 'lfdnr', type: Types::INTEGER, nullable: false)]
27    #[ORM\Id]
28    #[ORM\GeneratedValue(strategy: 'SEQUENCE')]
29    #[ORM\SequenceGenerator(sequenceName: 'GEN_LFDNR', allocationSize: 1, initialValue: 1)]
30    public private(set) ?int $lfdnr = null;
31
32    #[ORM\Column(name: 'gruppe', type: Types::STRING, length: 25, nullable: true)]
33    private ?string $name = null;
34
35    #[ORM\ManyToOne(targetEntity: Textauswahlgruppe::class, cascade: ['persist'], inversedBy: 'kinder')]
36    #[ORM\JoinColumn(name: 'vaterlfdnr', referencedColumnName: 'lfdnr')]
37    private ?Textauswahlgruppe $vater = null;
38
39    public function __construct(
40        ?string $name = null
41    ) {
42        if ($name !== null) {
43            $this->setName($name);
44        }
45        $this->kinder = new ArrayCollection();
46    }
47
48    public function addKind(self $gruppe): self
49    {
50        if (!$this->kinder->contains($gruppe)) {
51            $this->kinder->add($gruppe);
52            $gruppe->setVater($this);
53        }
54
55        return $this;
56    }
57
58    /**
59     * @return Collection<int, Textauswahlgruppe>
60     */
61    public function getKinder(): Collection
62    {
63        return $this->kinder;
64    }
65
66    public function getLfdnr(): ?int
67    {
68        return $this->lfdnr;
69    }
70
71    public function getName(): ?string
72    {
73        return $this->name;
74    }
75
76    public function setName(?string $name): self
77    {
78        $this->name = $name;
79
80        return $this;
81    }
82
83    public function getVater(): ?self
84    {
85        return $this->vater;
86    }
87
88    public function setVater(?self $vater): self
89    {
90        if ($this !== $vater) {
91            $this->vater = $vater;
92        }
93
94        return $this;
95    }
96
97    public function removeKind(self $gruppe): self
98    {
99        if ($this->kinder->contains($gruppe)) {
100            $this->kinder->removeElement($gruppe);
101            $gruppe->setVater(null);
102        }
103
104        return $this;
105    }
106}