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