1 | <?php // Copyright ⓒ 2018 Magneds IP B.V. - All Rights Reserved |
||||
2 | namespace Magneds\Lokalise\Project\Entity; |
||||
3 | |||||
4 | use DateTime; |
||||
5 | use DateTimeZone; |
||||
6 | |||||
7 | class Project |
||||
8 | { |
||||
9 | /** |
||||
10 | * @var string |
||||
11 | */ |
||||
12 | protected $id; |
||||
13 | |||||
14 | /** |
||||
15 | * @var string |
||||
16 | */ |
||||
17 | protected $name; |
||||
18 | |||||
19 | /** |
||||
20 | * @var string |
||||
21 | */ |
||||
22 | protected $description; |
||||
23 | |||||
24 | /** |
||||
25 | * @var DateTime |
||||
26 | */ |
||||
27 | protected $created; |
||||
28 | |||||
29 | /** |
||||
30 | * @var int |
||||
31 | */ |
||||
32 | protected $owner; |
||||
33 | |||||
34 | /** |
||||
35 | * Project constructor. |
||||
36 | * @param string $id |
||||
37 | * @param string $name |
||||
38 | * @param string $description |
||||
39 | * @param DateTime $created |
||||
40 | * @param int $owner |
||||
41 | */ |
||||
42 | public function __construct(ProjectID $id, string $name, string $description, DateTime $created, int $owner) |
||||
43 | { |
||||
44 | $this->id = $id; |
||||
45 | $this->name = $name; |
||||
46 | $this->description = $description; |
||||
47 | $this->created = $created; |
||||
48 | $this->owner = $owner; |
||||
49 | } |
||||
50 | |||||
51 | /** |
||||
52 | * @return ProjectID |
||||
53 | */ |
||||
54 | public function getID(): ProjectID |
||||
55 | { |
||||
56 | return $this->id; |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||
57 | } |
||||
58 | |||||
59 | /** |
||||
60 | * @return string |
||||
61 | */ |
||||
62 | public function getName(): string |
||||
63 | { |
||||
64 | return $this->name; |
||||
65 | } |
||||
66 | |||||
67 | /** |
||||
68 | * @return string |
||||
69 | */ |
||||
70 | public function getDescription(): string |
||||
71 | { |
||||
72 | return $this->description; |
||||
73 | } |
||||
74 | |||||
75 | /** |
||||
76 | * @return DateTime |
||||
77 | */ |
||||
78 | public function getCreated(): DateTime |
||||
79 | { |
||||
80 | return $this->created; |
||||
81 | } |
||||
82 | |||||
83 | /** |
||||
84 | * @return int |
||||
85 | */ |
||||
86 | public function getOwner(): int |
||||
87 | { |
||||
88 | return $this->owner; |
||||
89 | } |
||||
90 | |||||
91 | public static function buildFromArray($array) |
||||
92 | { |
||||
93 | $timezone = new DateTimeZone('Europe/Amsterdam'); |
||||
94 | $utc = new DateTimeZone('UTC'); |
||||
95 | |||||
96 | $created = DateTime::createFromFormat('Y-m-d H:i:s', $array['created'], $timezone); |
||||
97 | $created->setTimezone($utc); |
||||
98 | |||||
99 | return new Project(new ProjectID($array['id']), $array['name'], $array['desc'], $created, $array['owner']); |
||||
0 ignored issues
–
show
It seems like
$created can also be of type false ; however, parameter $created of Magneds\Lokalise\Project...\Project::__construct() does only seem to accept DateTime , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
100 | } |
||||
101 | } |
||||
102 |