Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 15 |
CRAP | |
0.00% |
0 / 1 |
Download | |
0.00% |
0 / 19 |
|
0.00% |
0 / 15 |
380 | |
0.00% |
0 / 1 |
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPosition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPosition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEntityNameForStorage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEntityIdForStorage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPositionFieldName | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getPositionForEntityField | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getIdFieldNameForSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getIdForSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTitleForSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCriteriaForFilter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCriteriaForQuery | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Entity\Service; |
4 | |
5 | use Doctrine\Common\Collections\Criteria; |
6 | use Doctrine\Common\Collections\Expr\Expression; |
7 | use Doctrine\ORM\Mapping as ORM; |
8 | use Olz\Entity\Common\DataStorageInterface; |
9 | use Olz\Entity\Common\DataStorageTrait; |
10 | use Olz\Entity\Common\OlzEntity; |
11 | use Olz\Entity\Common\PositionableInterface; |
12 | use Olz\Repository\Service\DownloadRepository; |
13 | |
14 | #[ORM\Table(name: 'downloads')] |
15 | #[ORM\Index(name: 'position_index', columns: ['on_off', 'position'])] |
16 | #[ORM\Entity(repositoryClass: DownloadRepository::class)] |
17 | class Download extends OlzEntity implements DataStorageInterface, PositionableInterface { |
18 | use DataStorageTrait; |
19 | |
20 | #[ORM\Id] |
21 | #[ORM\Column(type: 'integer', nullable: false)] |
22 | #[ORM\GeneratedValue] |
23 | private int $id; |
24 | |
25 | #[ORM\Column(type: 'text', nullable: true)] |
26 | private ?string $name; |
27 | |
28 | #[ORM\Column(type: 'smallfloat', nullable: false)] |
29 | private float $position; |
30 | |
31 | public function getId(): ?int { |
32 | return $this->id ?? null; |
33 | } |
34 | |
35 | public function setId(int $new_value): void { |
36 | $this->id = $new_value; |
37 | } |
38 | |
39 | public function getName(): ?string { |
40 | return $this->name; |
41 | } |
42 | |
43 | public function setName(?string $new_value): void { |
44 | $this->name = $new_value; |
45 | } |
46 | |
47 | public function getPosition(): float { |
48 | return $this->position; |
49 | } |
50 | |
51 | public function setPosition(float $new_value): void { |
52 | $this->position = $new_value; |
53 | } |
54 | |
55 | // --- |
56 | |
57 | public static function getEntityNameForStorage(): string { |
58 | return 'downloads'; |
59 | } |
60 | |
61 | public function getEntityIdForStorage(): string { |
62 | return "{$this->getId()}"; |
63 | } |
64 | |
65 | public static function getPositionFieldName(string $field): string { |
66 | switch ($field) { |
67 | case 'position': |
68 | return 'position'; |
69 | default: throw new \Exception("No such position field: {$field}"); |
70 | } |
71 | } |
72 | |
73 | public function getPositionForEntityField(string $field): ?float { |
74 | switch ($field) { |
75 | case 'position': |
76 | return $this->getPosition(); |
77 | default: throw new \Exception("No such position field: {$field}"); |
78 | } |
79 | } |
80 | |
81 | public static function getIdFieldNameForSearch(): string { |
82 | return 'id'; |
83 | } |
84 | |
85 | public function getIdForSearch(): int { |
86 | return $this->getId() ?? 0; |
87 | } |
88 | |
89 | public function getTitleForSearch(): string { |
90 | return $this->getName() ?? '---'; |
91 | } |
92 | |
93 | public static function getCriteriaForFilter(string $key, string $value): Expression { |
94 | throw new \Exception("No such Download filter: {$key}"); |
95 | } |
96 | |
97 | public static function getCriteriaForQuery(string $query): Expression { |
98 | return Criteria::expr()->contains('name', $query); |
99 | } |
100 | } |