Completed
Push — master ( 08acda...fe47f9 )
by Paweł
11s
created

Author::__toString()   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\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
    use PersistableAwareTrait, TimestampableAwareTrait;
17
18
    private $name;
19
20
    private $bio;
21
22
    private $picture;
23
24
    private $pictureFile;
25
26
    private $courses;
27
28
    public function __construct()
29
    {
30
        $this->courses = new ArrayCollection();
31
    }
32
33
    public function getName(): ?string
34
    {
35
        return $this->name;
36
    }
37
38
    public function setName(string $name): void
39
    {
40
        $this->name = $name;
41
    }
42
43
    public function getBio(): ?string
44
    {
45
        return $this->bio;
46
    }
47
48
    public function setBio(string $bio): void
49
    {
50
        $this->bio = $bio;
51
    }
52
53
    public function getPicture(): ?string
54
    {
55
        return $this->picture;
56
    }
57
58
    public function setPicture(string $picture): void
59
    {
60
        $this->picture = $picture;
61
    }
62
63
    public function getCourses(): Collection
64
    {
65
        return $this->courses;
66
    }
67
68
    public function getPictureFile(): ?File
69
    {
70
        return $this->pictureFile;
71
    }
72
73
    public function setPictureFile(File $pictureFile): void
74
    {
75
        $this->pictureFile = $pictureFile;
76
        $this->updated = new DateTimeImmutable();
77
    }
78
79
    public function setCourses(Collection $courses): void
80
    {
81
        $this->courses = $courses;
82
    }
83
84
    public function addCourse(CourseInterface $course): void
85
    {
86
        if (!$this->courses->contains($course)) {
87
            $this->courses->add($course);
88
        }
89
    }
90
91
    public function removeCourse(CourseInterface $course): void
92
    {
93
        if (!$this->courses->contains($course)) {
94
            $this->courses->remove($course);
95
        }
96
    }
97
98
    public function __toString()
99
    {
100
        return $this->getName() ?? 'New Author';
101
    }
102
}
103