Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
SkillCategory | |
0.00% |
0 / 10 |
|
0.00% |
0 / 10 |
110 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getParentCategory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setParentCategory | |
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 | |||
getSkills | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addSkill | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
testOnlyGetField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Entity\Quiz; |
4 | |
5 | use Doctrine\Common\Collections\ArrayCollection; |
6 | use Doctrine\Common\Collections\Collection; |
7 | use Doctrine\ORM\Mapping as ORM; |
8 | use Olz\Entity\Common\OlzEntity; |
9 | use Olz\Entity\Common\TestableInterface; |
10 | use Olz\Repository\Quiz\SkillCategoryRepository; |
11 | |
12 | #[ORM\Table(name: 'quiz_categories')] |
13 | #[ORM\Index(name: 'name_index', columns: ['name'])] |
14 | #[ORM\Index(name: 'parent_category_index', columns: ['parent_category_id'])] |
15 | #[ORM\Entity(repositoryClass: SkillCategoryRepository::class)] |
16 | class SkillCategory extends OlzEntity implements TestableInterface { |
17 | #[ORM\Id] |
18 | #[ORM\Column(type: 'integer', nullable: false)] |
19 | #[ORM\GeneratedValue] |
20 | private int $id; |
21 | |
22 | #[ORM\ManyToOne(targetEntity: SkillCategory::class)] |
23 | #[ORM\JoinColumn(name: 'parent_category_id', referencedColumnName: 'id', nullable: true)] |
24 | private ?SkillCategory $parent_category; |
25 | |
26 | #[ORM\Column(type: 'string', nullable: false)] |
27 | private string $name; |
28 | |
29 | /** @var Collection<int|string, Skill>&iterable<Skill> */ |
30 | #[ORM\ManyToMany(targetEntity: Skill::class, mappedBy: 'categories')] |
31 | private Collection $skills; |
32 | |
33 | public function __construct() { |
34 | $this->skills = new ArrayCollection(); |
35 | } |
36 | |
37 | public function getId(): ?int { |
38 | return $this->id ?? null; |
39 | } |
40 | |
41 | public function setId(int $new_id): void { |
42 | $this->id = $new_id; |
43 | } |
44 | |
45 | public function getParentCategory(): ?SkillCategory { |
46 | return $this->parent_category; |
47 | } |
48 | |
49 | public function setParentCategory(?SkillCategory $new_parent_category): void { |
50 | $this->parent_category = $new_parent_category; |
51 | } |
52 | |
53 | public function getName(): string { |
54 | return $this->name; |
55 | } |
56 | |
57 | public function setName(string $new_name): void { |
58 | $this->name = $new_name; |
59 | } |
60 | |
61 | /** @return Collection<int|string, Skill>&iterable<Skill> */ |
62 | public function getSkills(): Collection { |
63 | return $this->skills; |
64 | } |
65 | |
66 | public function addSkill(Skill $new_skill): void { |
67 | $this->skills->add($new_skill); |
68 | } |
69 | |
70 | // --- |
71 | |
72 | public function testOnlyGetField(string $field_name): mixed { |
73 | return $this->{$field_name}; |
74 | } |
75 | } |