Completed
Push — master ( 0a29a7...583849 )
by Paweł
15s queued 11s
created

Author::getGender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Entity;
4
5
use App\Model\AuthorInterface;
6
use App\Model\CourseInterface;
7
use App\Model\PersistableAwareTrait;
8
use App\Model\TimestampableAwareTrait;
9
use DateTimeImmutable;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\Common\Collections\Collection;
12
use Symfony\Component\HttpFoundation\File\File;
13
14
class Author implements AuthorInterface
15
{
16
    public const AUTHOR_GENDER_MALE = 'male';
17
    public const AUTHOR_GENDER_FEMALE = 'female';
18
    public const AUTHOR_GENDER_OTHER = 'other';
19
20
    use PersistableAwareTrait, TimestampableAwareTrait;
21
22
    private $name;
23
24
    private $bio;
25
26
    private $picture;
27
28
    private $pictureFile;
29
30
    private $courses;
31
32
    private $gender = self::AUTHOR_GENDER_MALE;
33
34
    public function __construct()
35
    {
36
        $this->courses = new ArrayCollection();
37
    }
38
39
    public function getName(): ?string
40
    {
41
        return $this->name;
42
    }
43
44
    public function setName(string $name): void
45
    {
46
        $this->name = $name;
47
    }
48
49
    public function getBio(): ?string
50
    {
51
        return $this->bio;
52
    }
53
54
    public function setBio(string $bio): void
55
    {
56
        $this->bio = $bio;
57
    }
58
59
    public function getPicture(): ?string
60
    {
61
        return $this->picture;
62
    }
63
64
    public function setPicture(?string $picture): void
65
    {
66
        $this->picture = $picture;
67
    }
68
69
    public function getCourses(): Collection
70
    {
71
        return $this->courses;
72
    }
73
74
    public function getPictureFile(): ?File
75
    {
76
        return $this->pictureFile;
77
    }
78
79
    public function setPictureFile(File $pictureFile): void
80
    {
81
        $this->pictureFile = $pictureFile;
82
        $this->updated = new DateTimeImmutable();
83
    }
84
85
    public function setCourses(Collection $courses): void
86
    {
87
        $this->courses = $courses;
88
    }
89
90
    public function addCourse(CourseInterface $course): void
91
    {
92
        if (!$this->courses->contains($course)) {
93
            $this->courses->add($course);
94
        }
95
    }
96
97
    public function removeCourse(CourseInterface $course): void
98
    {
99
        if (!$this->courses->contains($course)) {
100
            $this->courses->remove($course);
101
        }
102
    }
103
104
    public function __toString()
105
    {
106
        return $this->getName() ?? 'New Author';
107
    }
108
109
    public function getGender(): string
110
    {
111
        return $this->gender;
112
    }
113
114
    public function setGender(string $gender): void
115
    {
116
        $this->gender = $gender;
117
    }
118
}
119