Completed
Push — master ( c5110b...a167e6 )
by Valentyn
13:46
created

ReleaseDateQueue::getAddedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Movies\Entity;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9
use Symfony\Component\Serializer\Annotation\Groups;
10
11
/**
12
 * @ORM\Entity(repositoryClass="App\Movies\Repository\ReleaseDateQueueRepository")
13
 * @UniqueEntity("movie_id")
14
 */
15
class ReleaseDateQueue
16
{
17
    /**
18
     * @ORM\Id()
19
     * @ORM\GeneratedValue()
20
     * @ORM\Column(type="integer")
21
     * @Groups({"list", "view"})
22
     */
23
    private $id;
24
25
    /**
26
     * @ORM\OneToOne(targetEntity="App\Movies\Entity\Movie")
27
     * @ORM\JoinColumn(nullable=false)
28
     * @Groups({"list", "view"})
29
     */
30
    private $movie;
31
32
    /**
33
     * @Groups({"list", "view"})
34
     * @ORM\Column(type="date", nullable=true)
35
     */
36
    private $addedAt;
37
38
    /**
39
     * @Groups({"list", "view"})
40
     * @ORM\Column(type="integer", nullable=false, options={"default": 1})
41
     */
42
    private $isActive;
43
44
    public function __construct(Movie $movie)
45
    {
46
        $this->movie = $movie;
47
        $this->addedAt = new \DateTime();
48
49
        if (!$movie->getImdbId()) {
50
            $this->isActive = 0;
51
        }
52
    }
53
54
    public function getId(): int
55
    {
56
        return $this->id;
57
    }
58
59
    public function getMovie(): Movie
60
    {
61
        return $this->movie;
62
    }
63
64
    public function getAddedAt(): \DateTimeInterface
65
    {
66
        return $this->addedAt;
67
    }
68
69
    public function activate()
70
    {
71
        $this->isActive = 1;
72
    }
73
74
    public function isActive(): bool
75
    {
76
        return $this->isActive === 1 ? true : false;
77
    }
78
}
79