Index   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 178
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 19
c 1
b 0
f 0
dl 0
loc 178
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getTags() 0 3 1
A addTag() 0 8 2
A getIndexationDate() 0 3 1
A getValue() 0 3 1
A getVacancyId() 0 3 1
A getId() 0 3 1
A setVacancyId() 0 3 1
A setValue() 0 3 1
A setIndexationDate() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\SanityBundle\Entity\Vacancy;
17
18
use DateTimeInterface;
19
use Doctrine\Common\Collections\ArrayCollection;
20
use Doctrine\Common\Collections\Collection;
21
use Doctrine\ORM\Mapping as ORM;
22
23
/**
24
 * Sanity index
25
 *
26
 * @ORM\Table(name="sanity_vacancy_index")
27
 * @ORM\Entity(repositoryClass="Veslo\SanityBundle\Entity\Repository\Vacancy\IndexRepository", readOnly=true)
28
 * @ORM\Cache(usage="READ_ONLY", region="index")
29
 */
30
class Index
31
{
32
    /**
33
     * Sanity index identifier
34
     *
35
     * @var int
36
     *
37
     * @ORM\Column(name="id", type="integer", options={"comment": "Sanity index identifier"})
38
     * @ORM\Id
39
     * @ORM\GeneratedValue(strategy="AUTO")
40
     */
41
    private $id;
42
43
    /**
44
     * Vacancy identifier to which sanity index belongs to
45
     *
46
     * @var int
47
     *
48
     * @ORM\Column(
49
     *     name="vacancy_id",
50
     *     type="integer",
51
     *     unique=true,
52
     *     options={"comment": "Vacancy identifier to which sanity index belongs to"}
53
     * )
54
     */
55
    private $vacancyId;
56
57
    /**
58
     * Sanity index value, from 0.00 to 100.00
59
     *
60
     * @var float
61
     *
62
     * @ORM\Column(
63
     *     name="value",
64
     *     type="float",
65
     *     precision=5,
66
     *     scale=2,
67
     *     options={"unsigned": true, "comment": "Sanity index value, from 0.00 to 100.00"}
68
     * )
69
     */
70
    private $value;
71
72
    /**
73
     * Sanity tags which was offered for a vacancy by indexation result
74
     *
75
     * @var Collection<Tag>
76
     *
77
     * @ORM\ManyToMany(targetEntity="Veslo\SanityBundle\Entity\Vacancy\Tag", inversedBy="indexes")
78
     * @ORM\JoinTable(
79
     *     name="sanity_vacancy_index_sanity_vacancy_tag",
80
     *     joinColumns={@ORM\JoinColumn(name="index_id", referencedColumnName="id")},
81
     *     inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")}
82
     * )
83
     */
84
    private $tags;
85
86
    /**
87
     * Date and time when sanity index was created
88
     *
89
     * @var DateTimeInterface
90
     *
91
     * @ORM\Column(
92
     *     name="indexation_date",
93
     *     type="datetime",
94
     *     options={"comment": "Date and time when sanity index was created"}
95
     * )
96
     */
97
    private $indexationDate;
98
99
    /**
100
     * Index constructor.
101
     */
102
    public function __construct()
103
    {
104
        $this->tags = new ArrayCollection();
105
    }
106
107
    /**
108
     * Returns sanity index identifier
109
     *
110
     * @return int
111
     */
112
    public function getId(): int
113
    {
114
        return $this->id;
115
    }
116
117
    /**
118
     * Returns vacancy identifier to which sanity index belongs to
119
     *
120
     * @return int
121
     */
122
    public function getVacancyId(): int
123
    {
124
        return $this->vacancyId;
125
    }
126
127
    /**
128
     * Sets vacancy identifier to which sanity index belongs to
129
     *
130
     * @param int $vacancyId Vacancy identifier to which sanity index belongs to
131
     *
132
     * @return void
133
     */
134
    public function setVacancyId(int $vacancyId): void
135
    {
136
        $this->vacancyId = $vacancyId;
137
    }
138
139
    /**
140
     * Returns sanity index value, from 0.00 to 100.00
141
     *
142
     * @return float
143
     */
144
    public function getValue(): float
145
    {
146
        return $this->value;
147
    }
148
149
    /**
150
     * Sets sanity index value
151
     *
152
     * @param float $value Sanity index value, from 0.00 to 100.00
153
     *
154
     * @return void
155
     */
156
    public function setValue(float $value): void
157
    {
158
        $this->value = $value;
159
    }
160
161
    /**
162
     * Returns sanity tags which was offered for vacancy by indexation result
163
     *
164
     * @return Tag[]
165
     */
166
    public function getTags(): array
167
    {
168
        return $this->tags->toArray();
169
    }
170
171
    /**
172
     * Adds a sanity tag which was offered for vacancy by indexation result
173
     *
174
     * @param Tag $tag Sanity tag
175
     *
176
     * @return void
177
     */
178
    public function addTag(Tag $tag): void
179
    {
180
        if ($this->tags->contains($tag)) {
181
            return;
182
        }
183
184
        $this->tags->add($tag);
185
        $tag->addIndex($this);
186
    }
187
188
    /**
189
     * Returns date and time when sanity index was created
190
     *
191
     * @return DateTimeInterface
192
     */
193
    public function getIndexationDate(): DateTimeInterface
194
    {
195
        return $this->indexationDate;
196
    }
197
198
    /**
199
     * Sets date and time when sanity index was created
200
     *
201
     * @param DateTimeInterface $indexationDate Date and time when sanity index was created
202
     *
203
     * @return void
204
     */
205
    public function setIndexationDate(DateTimeInterface $indexationDate): void
206
    {
207
        $this->indexationDate = $indexationDate;
208
    }
209
}
210