Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 20 |
CRAP | |
0.00% |
0 / 1 |
| TerminLocation | |
0.00% |
0 / 28 |
|
0.00% |
0 / 20 |
552 | |
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 | |||
| getDetails | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setDetails | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLatitude | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setLatitude | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLongitude | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setLongitude | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getImageIds | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| setImageIds | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| testOnlyGetField | |
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 | |||
| 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 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Entity\Termine; |
| 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\SearchableInterface; |
| 12 | use Olz\Entity\Common\TestableInterface; |
| 13 | use Olz\Repository\Termine\TerminLocationRepository; |
| 14 | |
| 15 | #[ORM\Table(name: 'termin_locations')] |
| 16 | #[ORM\Index(name: 'name_index', columns: ['name'])] |
| 17 | #[ORM\Entity(repositoryClass: TerminLocationRepository::class)] |
| 18 | class TerminLocation extends OlzEntity implements DataStorageInterface, SearchableInterface, TestableInterface { |
| 19 | use DataStorageTrait; |
| 20 | |
| 21 | #[ORM\Id] |
| 22 | #[ORM\Column(type: 'integer', nullable: false)] |
| 23 | #[ORM\GeneratedValue] |
| 24 | private int $id; |
| 25 | |
| 26 | #[ORM\Column(type: 'string', length: 127, nullable: false)] |
| 27 | private string $name; |
| 28 | |
| 29 | #[ORM\Column(type: 'text', nullable: true)] |
| 30 | private ?string $details; |
| 31 | |
| 32 | #[ORM\Column(type: 'float', nullable: false)] |
| 33 | private float $latitude; |
| 34 | |
| 35 | #[ORM\Column(type: 'float', nullable: false)] |
| 36 | private float $longitude; |
| 37 | |
| 38 | #[ORM\Column(type: 'text', nullable: true)] |
| 39 | private ?string $image_ids; |
| 40 | |
| 41 | public function getId(): ?int { |
| 42 | return $this->id ?? null; |
| 43 | } |
| 44 | |
| 45 | public function setId(int $new_value): void { |
| 46 | $this->id = $new_value; |
| 47 | } |
| 48 | |
| 49 | public function getName(): string { |
| 50 | return $this->name; |
| 51 | } |
| 52 | |
| 53 | public function setName(string $new_value): void { |
| 54 | $this->name = $new_value; |
| 55 | } |
| 56 | |
| 57 | public function getDetails(): ?string { |
| 58 | return $this->details; |
| 59 | } |
| 60 | |
| 61 | public function setDetails(?string $new_value): void { |
| 62 | $this->details = $new_value; |
| 63 | } |
| 64 | |
| 65 | public function getLatitude(): float { |
| 66 | return $this->latitude; |
| 67 | } |
| 68 | |
| 69 | public function setLatitude(float $new_value): void { |
| 70 | $this->latitude = $new_value; |
| 71 | } |
| 72 | |
| 73 | public function getLongitude(): float { |
| 74 | return $this->longitude; |
| 75 | } |
| 76 | |
| 77 | public function setLongitude(float $new_value): void { |
| 78 | $this->longitude = $new_value; |
| 79 | } |
| 80 | |
| 81 | /** @return array<string> */ |
| 82 | public function getImageIds(): array { |
| 83 | if ($this->image_ids == null) { |
| 84 | return []; |
| 85 | } |
| 86 | $array = json_decode($this->image_ids, true); |
| 87 | return is_array($array) ? $array : []; |
| 88 | } |
| 89 | |
| 90 | /** @param array<string> $new_value */ |
| 91 | public function setImageIds(array $new_value): void { |
| 92 | $enc_value = json_encode($new_value); |
| 93 | if (!$enc_value) { |
| 94 | return; |
| 95 | } |
| 96 | $this->image_ids = $enc_value; |
| 97 | } |
| 98 | |
| 99 | // --- |
| 100 | |
| 101 | public function testOnlyGetField(string $field_name): mixed { |
| 102 | return $this->{$field_name}; |
| 103 | } |
| 104 | |
| 105 | public static function getEntityNameForStorage(): string { |
| 106 | return 'termin_locations'; |
| 107 | } |
| 108 | |
| 109 | public function getEntityIdForStorage(): string { |
| 110 | return "{$this->getId()}"; |
| 111 | } |
| 112 | |
| 113 | public static function getIdFieldNameForSearch(): string { |
| 114 | return 'id'; |
| 115 | } |
| 116 | |
| 117 | public function getIdForSearch(): int { |
| 118 | return $this->getId() ?? 0; |
| 119 | } |
| 120 | |
| 121 | public function getTitleForSearch(): string { |
| 122 | return $this->getName(); |
| 123 | } |
| 124 | |
| 125 | public static function getCriteriaForFilter(string $key, string $value): Expression { |
| 126 | throw new \Exception("No such TerminLocation filter: {$key}"); |
| 127 | } |
| 128 | |
| 129 | public static function getCriteriaForQuery(string $query): Expression { |
| 130 | return Criteria::expr()->orX( |
| 131 | Criteria::expr()->contains('name', $query), |
| 132 | ); |
| 133 | } |
| 134 | } |