|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace App\Movies\DTO; |
|
5
|
|
|
|
|
6
|
|
|
class MovieDTO |
|
7
|
|
|
{ |
|
8
|
|
|
private $originalTitle, $originalPosterUrl, $imdbId, $budget, $runtime, $releaseDate; |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* MovieDTO constructor. |
|
12
|
|
|
* @param null|string $originalTitle |
|
13
|
|
|
* @param null|string $originalPosterUrl |
|
14
|
|
|
* @param null|string $imdbId |
|
15
|
|
|
* @param int|null $budget |
|
16
|
|
|
* @param int|null $runtime |
|
17
|
|
|
* @param null|string $releaseDate |
|
18
|
|
|
* @throws \Exception |
|
19
|
|
|
*/ |
|
20
|
2 |
|
public function __construct(?string $originalTitle, ?string $originalPosterUrl, ?string $imdbId, ?int $budget, ?int $runtime, ?string $releaseDate) |
|
21
|
|
|
{ |
|
22
|
2 |
|
$this->originalTitle = $originalTitle; |
|
23
|
2 |
|
$this->originalPosterUrl = $originalPosterUrl; |
|
24
|
2 |
|
$this->imdbId = $imdbId; |
|
25
|
2 |
|
$this->budget = $budget; |
|
26
|
2 |
|
$this->runtime = $runtime; |
|
27
|
2 |
|
$this->releaseDate = new \DateTimeImmutable($releaseDate); |
|
28
|
2 |
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return null|string |
|
32
|
|
|
*/ |
|
33
|
2 |
|
public function getOriginalTitle(): ?string |
|
34
|
|
|
{ |
|
35
|
2 |
|
return $this->originalTitle; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @return null|string |
|
40
|
|
|
*/ |
|
41
|
2 |
|
public function getOriginalPosterUrl(): ?string |
|
42
|
|
|
{ |
|
43
|
2 |
|
return $this->originalPosterUrl; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return null|string |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getImdbId(): ?string |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->imdbId; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return int |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getBudget(): int |
|
58
|
|
|
{ |
|
59
|
|
|
return (int)$this->budget; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return int |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getRuntime(): int |
|
66
|
|
|
{ |
|
67
|
|
|
return (int)$this->runtime; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return \DateTimeImmutable |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getReleaseDate(): \DateTimeImmutable |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->releaseDate; |
|
76
|
|
|
} |
|
77
|
|
|
} |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.