Passed
Push — master ( fc8817...f91339 )
by Angel Fernando Quiroz
10:10 queued 10s
created

TopLink   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 39
dl 0
loc 97
rs 10
c 0
b 0
f 0
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A setTarget() 0 5 1
A setIcon() 0 5 1
A setUrl() 0 5 1
A setTitle() 0 5 1
A getIcon() 0 3 1
A getTools() 0 3 1
A __construct() 0 5 1
A getTitle() 0 3 1
A getTarget() 0 3 1
A getId() 0 3 1
A getUrl() 0 3 1
A addTool() 0 8 1
1
<?php
2
3
/* For license terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\TopLinks\Entity;
6
7
use Chamilo\CourseBundle\Entity\CTool;
8
use Chamilo\PluginBundle\TopLinks\Repository\TopLinkRepository\Entity;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\Common\Collections\Collection;
11
use Doctrine\ORM\Mapping as ORM;
12
13
#[ORM\Table(name: 'toplinks_link')]
14
#[ORM\Entity(repositoryClass: TopLinkRepository::class)]
15
class TopLink
16
{
17
    #[ORM\Column(name: 'id', type: 'integer')]
18
    #[ORM\Id]
19
    #[ORM\GeneratedValue]
20
    private ?int $id;
21
22
    #[ORM\Column(name: 'title', type: 'string')]
23
    private string $title;
24
25
    #[ORM\Column(name: 'url', type: 'text')]
26
    private string $url;
27
28
    #[ORM\Column(name: 'target', type: 'string', length: 10, options: ['default' => '_blank'])]
29
    private string $target;
30
31
    #[ORM\Column(name: 'icon', type: 'string', nullable: true)]
32
    private ?string $icon;
33
34
    #[ORM\OneToMany(mappedBy: 'link', targetEntity: TopLinkRelTool::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
35
    private Collection $tools;
36
37
    public function __construct()
38
    {
39
        $this->target = '_blank';
40
        $this->icon = null;
41
        $this->tools = new ArrayCollection();
42
    }
43
44
    public function getId(): ?int
45
    {
46
        return $this->id;
47
    }
48
49
    public function getTitle(): string
50
    {
51
        return $this->title;
52
    }
53
54
    public function setTitle(string $title): static
55
    {
56
        $this->title = $title;
57
58
        return $this;
59
    }
60
61
    public function getUrl(): string
62
    {
63
        return $this->url;
64
    }
65
66
    public function setUrl(string $url): static
67
    {
68
        $this->url = $url;
69
70
        return $this;
71
    }
72
73
    public function getTarget(): string
74
    {
75
        return $this->target;
76
    }
77
78
    public function setTarget(string $target): static
79
    {
80
        $this->target = $target;
81
82
        return $this;
83
    }
84
85
    public function getIcon(): ?string
86
    {
87
        return $this->icon;
88
    }
89
90
    public function setIcon(string $icon = null): static
91
    {
92
        $this->icon = $icon;
93
94
        return $this;
95
    }
96
97
    public function getTools(): Collection
98
    {
99
        return $this->tools;
100
    }
101
102
    public function addTool(CTool $tool): void
103
    {
104
        $linkTool = new TopLinkRelTool();
105
        $linkTool
106
            ->setTool($tool)
107
            ->setLink($this);
108
109
        $this->tools->add($linkTool);
110
    }
111
}
112