Passed
Pull Request — master (#4)
by Paweł
03:07
created

Lesson::setEmbedCode()   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
nc 1
nop 1
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
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 Symfony\Component\HttpFoundation\File\File;
11
12
class Lesson implements LessonInterface
13
{
14
    use TimestampableAwareTrait, SortableAwareTrait, PersistableAwareTrait;
15
16
    private $title;
17
18
    private $description;
19
20
    private $embedCode;
21
22
    private $module;
23
24
    private $completed;
25
26
    private $coverImageName;
27
28
    /**
29
     * Hack for PropertyInfo issues with File.
30
     *
31
     * @var null
32
     */
33
    private $coverImageFile;
34
35
    public function getTitle(): ?string
36
    {
37
        return $this->title;
38
    }
39
40
    public function setTitle(string $title): void
41
    {
42
        $this->title = $title;
43
    }
44
45
    public function getDescription(): ?string
46
    {
47
        return $this->description;
48
    }
49
50
    public function setDescription(string $description): void
51
    {
52
        $this->description = $description;
53
    }
54
55
    public function getEmbedCode(): ?string
56
    {
57
        return $this->embedCode;
58
    }
59
60
    public function setEmbedCode(string $embedCode): void
61
    {
62
        $this->embedCode = $embedCode;
63
    }
64
65
    public function getModule(): ?Module
66
    {
67
        return $this->module;
68
    }
69
70
    public function setModule(?Module $module): void
71
    {
72
        $this->module = $module;
73
    }
74
75
    public function getCompleted(): ?bool
76
    {
77
        return $this->completed;
78
    }
79
80
    public function setCompleted(?bool $completed): void
81
    {
82
        $this->completed = $completed;
83
    }
84
85
    public function getCoverImageName(): ?string
86
    {
87
        return $this->coverImageName;
88
    }
89
90
    public function setCoverImageName(?string $coverImageName): void
91
    {
92
        $this->coverImageName = $coverImageName;
93
    }
94
95
    public function setCoverImageFile(?File $coverImageFile = null): void
96
    {
97
        $this->coverImageFile = $coverImageFile;
1 ignored issue
show
Documentation Bug introduced by
It seems like $coverImageFile can also be of type Symfony\Component\HttpFoundation\File\File. However, the property $coverImageFile is declared as type null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
98
        $this->updated = new DateTime();
99
    }
100
101
    public function getCoverImageFile(): ?File
102
    {
103
        return $this->coverImageFile;
104
    }
105
}
106