Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 16 |
CRAP | |
0.00% |
0 / 1 |
| Link | |
0.00% |
0 / 20 |
|
0.00% |
0 / 16 |
420 | |
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 | |||
| getUrl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setUrl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| testOnlyGetField | |
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\OlzEntity; |
| 9 | use Olz\Entity\Common\PositionableInterface; |
| 10 | use Olz\Entity\Common\TestableInterface; |
| 11 | use Olz\Repository\Service\LinkRepository; |
| 12 | |
| 13 | #[ORM\Table(name: 'links')] |
| 14 | #[ORM\Index(name: 'position_index', columns: ['on_off', 'position'])] |
| 15 | #[ORM\Entity(repositoryClass: LinkRepository::class)] |
| 16 | class Link extends OlzEntity implements PositionableInterface, TestableInterface { |
| 17 | #[ORM\Id] |
| 18 | #[ORM\Column(type: 'integer', nullable: false)] |
| 19 | #[ORM\GeneratedValue] |
| 20 | private int $id; |
| 21 | |
| 22 | #[ORM\Column(type: 'text', nullable: true)] |
| 23 | private ?string $name; |
| 24 | |
| 25 | #[ORM\Column(type: 'smallfloat', nullable: false)] |
| 26 | private float $position; |
| 27 | |
| 28 | #[ORM\Column(type: 'text', nullable: true)] |
| 29 | private ?string $url; |
| 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 | public function getUrl(): ?string { |
| 56 | return $this->url; |
| 57 | } |
| 58 | |
| 59 | public function setUrl(?string $new_value): void { |
| 60 | $this->url = $new_value; |
| 61 | } |
| 62 | |
| 63 | // --- |
| 64 | |
| 65 | public function testOnlyGetField(string $field_name): mixed { |
| 66 | return $this->{$field_name}; |
| 67 | } |
| 68 | |
| 69 | public static function getPositionFieldName(string $field): string { |
| 70 | switch ($field) { |
| 71 | case 'position': |
| 72 | return 'position'; |
| 73 | default: throw new \Exception("No such position field: {$field}"); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | public function getPositionForEntityField(string $field): ?float { |
| 78 | switch ($field) { |
| 79 | case 'position': |
| 80 | return $this->getPosition(); |
| 81 | default: throw new \Exception("No such position field: {$field}"); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | public static function getIdFieldNameForSearch(): string { |
| 86 | return 'id'; |
| 87 | } |
| 88 | |
| 89 | public function getIdForSearch(): int { |
| 90 | return $this->getId() ?? 0; |
| 91 | } |
| 92 | |
| 93 | public function getTitleForSearch(): string { |
| 94 | return $this->getName() ?? '---'; |
| 95 | } |
| 96 | |
| 97 | public static function getCriteriaForFilter(string $key, string $value): Expression { |
| 98 | throw new \Exception("No such Link filter: {$key}"); |
| 99 | } |
| 100 | |
| 101 | public static function getCriteriaForQuery(string $query): Expression { |
| 102 | return Criteria::expr()->contains('name', $query); |
| 103 | } |
| 104 | } |