Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
Subject
83.33% covered (warning)
83.33%
5 / 6
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
5.20
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getWord
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUsageCount
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 incrementUsageCount
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLastUsedAt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6
7/**
8 * @author Wilhelm Zwertvaegher
9 */
10#[ORM\Entity]
11#[ORM\Table(name: 'subject')]
12#[ORM\UniqueConstraint(name: 'uq_subject_word', columns: ['word_id'])]
13class Subject implements GrammaticalRole
14{
15    #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
16    private int $id;
17
18    #[ORM\ManyToOne(targetEntity: Word::class)]
19    #[ORM\JoinColumn(nullable: false)]
20    private Word $word;
21
22    #[ORM\Column(type: 'integer')]
23    private int $usageCount = 0;
24
25    #[ORM\Column(type: 'datetime_immutable', nullable: true)]
26    private ?\DateTimeImmutable $lastUsedAt;
27
28    public function __construct(Word $word)
29    {
30        $this->word = $word;
31    }
32
33    public function getWord(): Word
34    {
35        return $this->word;
36    }
37
38    public function getUsageCount(): int
39    {
40        return $this->usageCount;
41    }
42
43    public function incrementUsageCount(\DateTimeImmutable $usedAt): void
44    {
45        ++$this->usageCount;
46        $this->lastUsedAt = $usedAt;
47    }
48
49    public function getLastUsedAt(): ?\DateTimeImmutable
50    {
51        return $this->lastUsedAt;
52    }
53}