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