Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 16
CRAP
0.00% covered (danger)
0.00%
0 / 1
Download
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 16
420
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
 testOnlyGetField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEntityNameForStorage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEntityIdForStorage
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\DataStorageInterface;
9use Olz\Entity\Common\DataStorageTrait;
10use Olz\Entity\Common\OlzEntity;
11use Olz\Entity\Common\PositionableInterface;
12use Olz\Entity\Common\TestableInterface;
13use Olz\Repository\Service\DownloadRepository;
14
15#[ORM\Table(name: 'downloads')]
16#[ORM\Index(name: 'position_index', columns: ['on_off', 'position'])]
17#[ORM\Entity(repositoryClass: DownloadRepository::class)]
18class Download extends OlzEntity implements DataStorageInterface, PositionableInterface, 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: 'text', nullable: true)]
27    private ?string $name;
28
29    #[ORM\Column(type: 'smallfloat', nullable: false)]
30    private float $position;
31
32    public function getId(): ?int {
33        return $this->id ?? null;
34    }
35
36    public function setId(int $new_value): void {
37        $this->id = $new_value;
38    }
39
40    public function getName(): ?string {
41        return $this->name;
42    }
43
44    public function setName(?string $new_value): void {
45        $this->name = $new_value;
46    }
47
48    public function getPosition(): float {
49        return $this->position;
50    }
51
52    public function setPosition(float $new_value): void {
53        $this->position = $new_value;
54    }
55
56    // ---
57
58    public function testOnlyGetField(string $field_name): mixed {
59        return $this->{$field_name};
60    }
61
62    public static function getEntityNameForStorage(): string {
63        return 'downloads';
64    }
65
66    public function getEntityIdForStorage(): string {
67        return "{$this->getId()}";
68    }
69
70    public static function getPositionFieldName(string $field): string {
71        switch ($field) {
72            case 'position':
73                return 'position';
74            default: throw new \Exception("No such position field: {$field}");
75        }
76    }
77
78    public function getPositionForEntityField(string $field): ?float {
79        switch ($field) {
80            case 'position':
81                return $this->getPosition();
82            default: throw new \Exception("No such position field: {$field}");
83        }
84    }
85
86    public static function getIdFieldNameForSearch(): string {
87        return 'id';
88    }
89
90    public function getIdForSearch(): int {
91        return $this->getId() ?? 0;
92    }
93
94    public function getTitleForSearch(): string {
95        return $this->getName() ?? '---';
96    }
97
98    public static function getCriteriaForFilter(string $key, string $value): Expression {
99        throw new \Exception("No such Download filter: {$key}");
100    }
101
102    public static function getCriteriaForQuery(string $query): Expression {
103        return Criteria::expr()->contains('name', $query);
104    }
105}