Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 23
CRAP
0.00% covered (danger)
0.00%
0 / 1
TerminLabel
0.00% covered (danger)
0.00%
0 / 30
0.00% covered (danger)
0.00%
0 / 23
756
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIdent
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setIdent
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDetails
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDetails
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIcon
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setIcon
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPosition
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setPosition
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 testOnlyGetField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEntityNameForStorage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEntityIdForStorage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPositionFieldName
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 getPositionForEntityField
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 getIdFieldNameForSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIdForSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTitleForSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCriteriaForFilter
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCriteriaForQuery
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Entity\Termine;
4
5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\Common\Collections\Collection;
7use Doctrine\Common\Collections\Criteria;
8use Doctrine\Common\Collections\Expr\Expression;
9use Doctrine\ORM\Mapping as ORM;
10use Olz\Entity\Common\DataStorageInterface;
11use Olz\Entity\Common\DataStorageTrait;
12use Olz\Entity\Common\OlzEntity;
13use Olz\Entity\Common\PositionableInterface;
14use Olz\Entity\Common\SearchableInterface;
15use Olz\Entity\Common\TestableInterface;
16use Olz\Repository\Termine\TerminLabelRepository;
17
18#[ORM\Table(name: 'termin_labels')]
19#[ORM\Index(name: 'ident_index', columns: ['on_off', 'ident'])]
20#[ORM\Index(name: 'name_index', columns: ['name'])]
21#[ORM\Index(name: 'position_index', columns: ['on_off', 'position'])]
22#[ORM\Entity(repositoryClass: TerminLabelRepository::class)]
23class TerminLabel extends OlzEntity implements DataStorageInterface, PositionableInterface, SearchableInterface, TestableInterface {
24    use DataStorageTrait;
25
26    #[ORM\Id]
27    #[ORM\Column(type: 'integer', nullable: false)]
28    #[ORM\GeneratedValue]
29    private int $id;
30
31    #[ORM\Column(type: 'string', length: 31, nullable: false)]
32    private string $ident;
33
34    #[ORM\Column(type: 'string', length: 127, nullable: false)]
35    private string $name;
36
37    #[ORM\Column(type: 'text', nullable: true)]
38    private ?string $details;
39
40    #[ORM\Column(type: 'text', nullable: true)]
41    private ?string $icon;
42
43    #[ORM\Column(type: 'smallfloat', nullable: false)]
44    private float $position;
45
46    /** @var Collection<int|string, Termin>&iterable<Termin> */
47    #[ORM\ManyToMany(targetEntity: Termin::class, mappedBy: 'labels')]
48    private Collection $termine;
49
50    /** @var Collection<int|string, TerminTemplate>&iterable<TerminTemplate> */
51    #[ORM\ManyToMany(targetEntity: TerminTemplate::class, mappedBy: 'labels')]
52    private Collection $termin_templates;
53
54    public function __construct() {
55        $this->termine = new ArrayCollection();
56        $this->termin_templates = new ArrayCollection();
57    }
58
59    public function getId(): ?int {
60        return $this->id ?? null;
61    }
62
63    public function setId(int $new_value): void {
64        $this->id = $new_value;
65    }
66
67    public function getIdent(): string {
68        return $this->ident;
69    }
70
71    public function setIdent(string $new_value): void {
72        $this->ident = $new_value;
73    }
74
75    public function getName(): string {
76        return $this->name;
77    }
78
79    public function setName(string $new_value): void {
80        $this->name = $new_value;
81    }
82
83    public function getDetails(): ?string {
84        return $this->details;
85    }
86
87    public function setDetails(?string $new_value): void {
88        $this->details = $new_value;
89    }
90
91    public function getIcon(): ?string {
92        return $this->icon;
93    }
94
95    public function setIcon(?string $new_value): void {
96        $this->icon = $new_value;
97    }
98
99    public function getPosition(): float {
100        return $this->position;
101    }
102
103    public function setPosition(float $new_value): void {
104        $this->position = $new_value;
105    }
106
107    // ---
108
109    public function testOnlyGetField(string $field_name): mixed {
110        return $this->{$field_name};
111    }
112
113    public static function getEntityNameForStorage(): string {
114        return 'termin_labels';
115    }
116
117    public function getEntityIdForStorage(): string {
118        return "{$this->getId()}";
119    }
120
121    public static function getPositionFieldName(string $field): string {
122        switch ($field) {
123            case 'position':
124                return 'position';
125            default: throw new \Exception("No such position field: {$field}");
126        }
127    }
128
129    public function getPositionForEntityField(string $field): ?float {
130        switch ($field) {
131            case 'position':
132                return $this->getPosition();
133            default: throw new \Exception("No such position field: {$field}");
134        }
135    }
136
137    public static function getIdFieldNameForSearch(): string {
138        return 'id';
139    }
140
141    public function getIdForSearch(): int {
142        return $this->getId() ?? 0;
143    }
144
145    public function getTitleForSearch(): string {
146        return $this->getName();
147    }
148
149    public static function getCriteriaForFilter(string $key, string $value): Expression {
150        throw new \Exception("No such TerminLabel filter: {$key}");
151    }
152
153    public static function getCriteriaForQuery(string $query): Expression {
154        return Criteria::expr()->orX(
155            Criteria::expr()->contains('name', $query),
156        );
157    }
158}