Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 15
CRAP
0.00% covered (danger)
0.00%
0 / 1
Link
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 15
380
0.00% covered (danger)
0.00%
0 / 1
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setId
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
 getPosition
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setPosition
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUrl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setUrl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPositionFieldName
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 getPositionForEntityField
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 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
 getTitleForSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCriteriaForFilter
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 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Entity\Service;
4
5use Doctrine\Common\Collections\Criteria;
6use Doctrine\Common\Collections\Expr\Expression;
7use Doctrine\ORM\Mapping as ORM;
8use Olz\Entity\Common\OlzEntity;
9use Olz\Entity\Common\PositionableInterface;
10use Olz\Repository\Service\LinkRepository;
11
12#[ORM\Table(name: 'links')]
13#[ORM\Index(name: 'position_index', columns: ['on_off', 'position'])]
14#[ORM\Entity(repositoryClass: LinkRepository::class)]
15class Link extends OlzEntity implements PositionableInterface {
16    #[ORM\Id]
17    #[ORM\Column(type: 'integer', nullable: false)]
18    #[ORM\GeneratedValue]
19    private int $id;
20
21    #[ORM\Column(type: 'text', nullable: true)]
22    private ?string $name;
23
24    #[ORM\Column(type: 'smallfloat', nullable: false)]
25    private float $position;
26
27    #[ORM\Column(type: 'text', nullable: true)]
28    private ?string $url;
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    public function getUrl(): ?string {
55        return $this->url;
56    }
57
58    public function setUrl(?string $new_value): void {
59        $this->url = $new_value;
60    }
61
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 Link filter: {$key}");
94    }
95
96    public static function getCriteriaForQuery(string $query): Expression {
97        return Criteria::expr()->contains('name', $query);
98    }
99}