Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 68
0.00% covered (danger)
0.00%
0 / 46
CRAP
0.00% covered (danger)
0.00%
0 / 1
SolvEvent
0.00% covered (danger)
0.00%
0 / 68
0.00% covered (danger)
0.00%
0 / 46
2550
0.00% covered (danger)
0.00%
0 / 1
 getSolvUid
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setSolvUid
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDate
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDate
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDuration
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDuration
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getKind
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setKind
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDayNight
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDayNight
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNational
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNational
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRegion
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setRegion
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setType
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
 getLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getClub
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setClub
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMap
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setMap
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLocation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLocation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCoordX
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCoordX
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCoordY
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCoordY
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDeadline
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDeadline
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEntryportal
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setEntryportal
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getStartLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setStartLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRankLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setRankLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLastModification
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLastModification
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFieldValue
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 setFieldValue
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 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
 getCriteriaForQuery
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
12
 getTitleForSearch
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Entity;
4
5use Doctrine\Common\Collections\Criteria;
6use Doctrine\Common\Collections\Expr\Expression;
7use Doctrine\ORM\Mapping as ORM;
8use Olz\Entity\Common\SearchableInterface;
9use Olz\Repository\SolvEventRepository;
10use Olz\Utils\WithUtilsTrait;
11
12#[ORM\Table(name: 'solv_events')]
13#[ORM\Index(name: 'date_index', columns: ['date'])]
14#[ORM\Entity(repositoryClass: SolvEventRepository::class)]
15class SolvEvent implements SearchableInterface {
16    use WithUtilsTrait;
17
18    #[ORM\Id]
19    #[ORM\Column(type: 'integer', nullable: false)]
20    private int $solv_uid;
21
22    #[ORM\Column(type: 'date', nullable: false)]
23    private \DateTime $date;
24
25    #[ORM\Column(type: 'integer', nullable: false)]
26    private int $duration;
27
28    #[ORM\Column(type: 'text', nullable: false)]
29    private string $kind;
30
31    #[ORM\Column(type: 'text', nullable: false)]
32    private string $day_night;
33
34    #[ORM\Column(type: 'integer', nullable: false)]
35    private int $national;
36
37    #[ORM\Column(type: 'text', nullable: false)]
38    private string $region;
39
40    #[ORM\Column(type: 'text', nullable: false)]
41    private string $type;
42
43    #[ORM\Column(type: 'text', nullable: false)]
44    private string $name;
45
46    #[ORM\Column(type: 'text', nullable: false)]
47    private string $link;
48
49    #[ORM\Column(type: 'text', nullable: false)]
50    private string $club;
51
52    #[ORM\Column(type: 'text', nullable: false)]
53    private string $map;
54
55    #[ORM\Column(type: 'text', nullable: false)]
56    private string $location;
57
58    #[ORM\Column(type: 'integer', nullable: false)]
59    private int $coord_x;
60
61    #[ORM\Column(type: 'integer', nullable: false)]
62    private int $coord_y;
63
64    #[ORM\Column(type: 'date', nullable: true)]
65    private ?\DateTime $deadline;
66
67    #[ORM\Column(type: 'integer', nullable: false)]
68    private int $entryportal;
69
70    #[ORM\Column(type: 'text', nullable: true)]
71    private ?string $start_link;
72
73    #[ORM\Column(type: 'text', nullable: true)]
74    private ?string $rank_link;
75
76    #[ORM\Column(type: 'datetime', nullable: false, options: ['default' => 'CURRENT_TIMESTAMP'])]
77    private \DateTime $last_modification;
78
79    /** @var array<string, true> */
80    private array $valid_field_names = [
81        'solv_uid' => true,
82        'date' => true,
83        'duration' => true,
84        'kind' => true,
85        'day_night' => true,
86        'national' => true,
87        'region' => true,
88        'type' => true,
89        'name' => true,
90        'link' => true,
91        'club' => true,
92        'map' => true,
93        'location' => true,
94        'coord_x' => true,
95        'coord_y' => true,
96        'deadline' => true,
97        'entryportal' => true,
98        'start_link' => true,
99        'rank_link' => true,
100        'last_modification' => true,
101    ];
102    // PRIMARY KEY (`solv_uid`)
103
104    public function getSolvUid(): int {
105        return $this->solv_uid;
106    }
107
108    public function setSolvUid(int $new_value): void {
109        $this->solv_uid = $new_value;
110    }
111
112    public function getDate(): \DateTime {
113        return $this->date;
114    }
115
116    public function setDate(\DateTime $new_value): void {
117        $this->date = $new_value;
118    }
119
120    public function getDuration(): int {
121        return $this->duration;
122    }
123
124    public function setDuration(int $new_value): void {
125        $this->duration = $new_value;
126    }
127
128    public function getKind(): string {
129        return $this->kind;
130    }
131
132    public function setKind(string $new_value): void {
133        $this->kind = $new_value;
134    }
135
136    public function getDayNight(): string {
137        return $this->day_night;
138    }
139
140    public function setDayNight(string $new_value): void {
141        $this->day_night = $new_value;
142    }
143
144    public function getNational(): int {
145        return $this->national;
146    }
147
148    public function setNational(int $new_value): void {
149        $this->national = $new_value;
150    }
151
152    public function getRegion(): string {
153        return $this->region;
154    }
155
156    public function setRegion(string $new_value): void {
157        $this->region = $new_value;
158    }
159
160    public function getType(): string {
161        return $this->type;
162    }
163
164    public function setType(string $new_value): void {
165        $this->type = $new_value;
166    }
167
168    public function getName(): string {
169        return $this->name;
170    }
171
172    public function setName(string $new_value): void {
173        $this->name = $new_value;
174    }
175
176    public function getLink(): string {
177        return $this->link;
178    }
179
180    public function setLink(string $new_value): void {
181        $this->link = $new_value;
182    }
183
184    public function getClub(): string {
185        return $this->club;
186    }
187
188    public function setClub(string $new_value): void {
189        $this->club = $new_value;
190    }
191
192    public function getMap(): string {
193        return $this->map;
194    }
195
196    public function setMap(string $new_value): void {
197        $this->map = $new_value;
198    }
199
200    public function getLocation(): string {
201        return $this->location;
202    }
203
204    public function setLocation(string $new_value): void {
205        $this->location = $new_value;
206    }
207
208    public function getCoordX(): int {
209        return $this->coord_x;
210    }
211
212    public function setCoordX(int $new_value): void {
213        $this->coord_x = $new_value;
214    }
215
216    public function getCoordY(): int {
217        return $this->coord_y;
218    }
219
220    public function setCoordY(int $new_value): void {
221        $this->coord_y = $new_value;
222    }
223
224    public function getDeadline(): ?\DateTime {
225        return $this->deadline;
226    }
227
228    public function setDeadline(?\DateTime $new_value): void {
229        $this->deadline = $new_value;
230    }
231
232    public function getEntryportal(): int {
233        return $this->entryportal;
234    }
235
236    public function setEntryportal(int $new_value): void {
237        $this->entryportal = $new_value;
238    }
239
240    public function getStartLink(): ?string {
241        return $this->start_link;
242    }
243
244    public function setStartLink(?string $new_value): void {
245        $this->start_link = $new_value;
246    }
247
248    public function getRankLink(): ?string {
249        return $this->rank_link;
250    }
251
252    public function setRankLink(?string $new_value): void {
253        $this->rank_link = $new_value;
254    }
255
256    public function getLastModification(): \DateTime {
257        return $this->last_modification;
258    }
259
260    public function setLastModification(\DateTime $new_value): void {
261        $this->last_modification = $new_value;
262    }
263
264    public function getFieldValue(string $field_name): mixed {
265        if (!isset($this->valid_field_names[$field_name])) {
266            throw new \Exception("getFieldValue: Invalid field name: {$field_name}", 1);
267        }
268        return $this->{$field_name};
269    }
270
271    public function setFieldValue(string $field_name, mixed $new_value): void {
272        if (!isset($this->valid_field_names[$field_name])) {
273            throw new \Exception("setFieldValue: Invalid field name: {$field_name}", 1);
274        }
275        $this->{$field_name} = $new_value;
276    }
277
278    // ---
279
280    public static function getIdFieldNameForSearch(): string {
281        return 'solv_uid';
282    }
283
284    public function getIdForSearch(): int {
285        return $this->getSolvUid();
286    }
287
288    public static function getCriteriaForQuery(string $query): Expression {
289        if (preg_match('/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/', $query)) {
290            return Criteria::expr()->orX(
291                Criteria::expr()->eq('date', new \DateTime($query)),
292                Criteria::expr()->contains('name', $query),
293            );
294        }
295        if (intval($query) > 1900) {
296            $this_year = strval(intval($query));
297            $next_year = strval(intval($query) + 1);
298            return Criteria::expr()->orX(
299                Criteria::expr()->andX(
300                    Criteria::expr()->gte('date', new \DateTime("{$this_year}-01-01 00:00:00")),
301                    Criteria::expr()->lt('date', new \DateTime("{$next_year}-01-01 00:00:00")),
302                ),
303                Criteria::expr()->contains('name', $query),
304            );
305        }
306        return Criteria::expr()->orX(
307            Criteria::expr()->contains('name', $query),
308        );
309    }
310
311    public function getTitleForSearch(): string {
312        $pretty_date = $this->getDate()->format('Y-m-d');
313        return "{$pretty_date}{$this->getName()}";
314    }
315}