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