Passed
Pull Request — master (#12)
by Paweł
03:22
created

Lesson::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Entity;
4
5
use App\Model\LessonInterface;
6
use App\Model\PersistableAwareTrait;
7
use App\Model\SortableAwareTrait;
8
use App\Model\TimestampableAwareTrait;
9
use DateTime;
10
use Serializable;
11
use Symfony\Component\HttpFoundation\File\File;
12
13
class Lesson implements LessonInterface, Serializable
14
{
15
    use TimestampableAwareTrait, SortableAwareTrait, PersistableAwareTrait;
16
17
    private $title;
18
19
    private $description;
20
21
    private $embedCode;
22
23
    private $module;
24
25
    private $coverImageName;
26
27
    private $durationInMinutes = 0;
28
29
    /**
30
     * Hack for PropertyInfo issues with File.
31
     *
32
     * @var null
33
     */
34
    private $coverImageFile;
35
36
    public function getTitle(): ?string
37
    {
38
        return $this->title;
39
    }
40
41
    public function setTitle(string $title): void
42
    {
43
        $this->title = $title;
44
    }
45
46
    public function getDescription(): ?string
47
    {
48
        return $this->description;
49
    }
50
51
    public function setDescription(string $description): void
52
    {
53
        $this->description = $description;
54
    }
55
56
    public function getEmbedCode(): ?string
57
    {
58
        return $this->embedCode;
59
    }
60
61
    public function setEmbedCode(string $embedCode): void
62
    {
63
        $this->embedCode = $embedCode;
64
    }
65
66
    public function getModule(): ?Module
67
    {
68
        return $this->module;
69
    }
70
71
    public function setModule(?Module $module): void
72
    {
73
        $this->module = $module;
74
    }
75
76
    public function getCoverImageName(): ?string
77
    {
78
        return $this->coverImageName;
79
    }
80
81
    public function setCoverImageName(?string $coverImageName): void
82
    {
83
        $this->coverImageName = $coverImageName;
84
    }
85
86
    public function setCoverImageFile(?File $coverImageFile = null): void
87
    {
88
        $this->coverImageFile = $coverImageFile;
89
        $this->updated = new DateTime();
90
    }
91
92
    public function getCoverImageFile(): ?File
93
    {
94
        return $this->coverImageFile;
95
    }
96
97
    public function getDurationInMinutes(): int
98
    {
99
        return $this->durationInMinutes;
100
    }
101
102
    public function setDurationInMinutes(int $durationInMinutes): void
103
    {
104
        $this->durationInMinutes = $durationInMinutes;
105
    }
106
107
    public function serialize(): void
108
    {
109
        $this->coverImageFile = null;
110
    }
111
112
    public function unserialize($serialized): void
113
    {
114
        $this->coverImageFile = null;
115
    }
116
117
    public function __toString()
118
    {
119
        return (string) $this->getTitle();
120
    }
121
}
122