Passed
Pull Request — master (#7124)
by
unknown
09:48
created

AttemptFile   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 74
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setComment() 0 5 1
A getAttempt() 0 3 1
A setResourceNode() 0 5 1
A clearResourceNode() 0 6 1
A getResourceNode() 0 3 1
A setAttempt() 0 5 1
A __construct() 0 4 1
A getComment() 0 3 1
A getId() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Entity;
8
9
use Doctrine\ORM\Mapping as ORM;
10
use Gedmo\Timestampable\Traits\TimestampableEntity;
11
use Symfony\Component\Uid\Uuid;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
#[ORM\Table(name: 'attempt_file')]
15
#[ORM\Entity]
16
class AttemptFile
17
{
18
    use TimestampableEntity;
19
20
    #[ORM\Id]
21
    #[ORM\Column(type: 'uuid')]
22
    protected Uuid $id;
23
24
    #[Assert\NotNull]
25
    #[ORM\ManyToOne(targetEntity: TrackEAttempt::class, inversedBy: 'attemptFiles')]
26
    #[ORM\JoinColumn(name: 'attempt_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
27
    protected TrackEAttempt $attempt;
28
29
    #[ORM\ManyToOne(targetEntity: ResourceNode::class)]
30
    protected ?ResourceNode $resourceNode = null;
31
32
    #[ORM\Column(name: 'comment', type: 'text', nullable: false)]
33
    protected string $comment;
34
35
    public function __construct()
36
    {
37
        $this->id = Uuid::v4();
38
        $this->comment = '';
39
    }
40
41
    public function getId(): Uuid
42
    {
43
        return $this->id;
44
    }
45
46
    public function getAttempt(): TrackEAttempt
47
    {
48
        return $this->attempt;
49
    }
50
51
    public function setAttempt(TrackEAttempt $attempt): self
52
    {
53
        $this->attempt = $attempt;
54
55
        return $this;
56
    }
57
58
    public function getResourceNode(): ?ResourceNode
59
    {
60
        return $this->resourceNode;
61
    }
62
63
    public function setResourceNode(?ResourceNode $resourceNode): self
64
    {
65
        $this->resourceNode = $resourceNode;
66
67
        return $this;
68
    }
69
70
    public function clearResourceNode(): self
71
    {
72
        // Detach the resource node reference when the file is removed.
73
        $this->resourceNode = null;
74
75
        return $this;
76
    }
77
78
    public function getComment(): string
79
    {
80
        return $this->comment;
81
    }
82
83
    public function setComment(string $comment): self
84
    {
85
        $this->comment = $comment;
86
87
        return $this;
88
    }
89
}
90