1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the prooph/php-ddd-cargo-sample package. |
4
|
|
|
* (c) Alexander Miertsch <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
declare(strict_types = 1); |
10
|
|
|
|
11
|
|
|
namespace Codeliner\CargoBackend\Model\Cargo; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Leg |
15
|
|
|
* |
16
|
|
|
* A Leg is part of an Itinerary. It describes a voyage from one location to another, with concrete load und unload times. |
17
|
|
|
* |
18
|
|
|
* @author Alexander Miertsch <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class Leg |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
private $loadLocation; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
private $unloadLocation; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var \DateTime |
34
|
|
|
*/ |
35
|
|
|
private $loadTime; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var \DateTime |
39
|
|
|
*/ |
40
|
|
|
private $unloadTime; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param string $aLoadLocation |
44
|
|
|
* @param string $anUnloadLocation |
45
|
|
|
* @param \DateTimeImmutable $aLoadTime |
46
|
|
|
* @param \DateTimeImmutable $anUnloadTime |
47
|
|
|
*/ |
48
|
|
|
public function __construct(string $aLoadLocation, |
49
|
|
|
string $anUnloadLocation, |
50
|
|
|
\DateTimeImmutable $aLoadTime, |
51
|
|
|
\DateTimeImmutable $anUnloadTime) |
52
|
|
|
{ |
53
|
|
|
$this->loadLocation = $aLoadLocation; |
54
|
|
|
$this->unloadLocation = $anUnloadLocation; |
55
|
|
|
$this->loadTime = $aLoadTime; |
|
|
|
|
56
|
|
|
$this->unloadTime = $anUnloadTime; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function loadLocation() |
63
|
|
|
{ |
64
|
|
|
return $this->loadLocation; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
public function unloadLocation() |
71
|
|
|
{ |
72
|
|
|
return $this->unloadLocation; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return \DateTimeImmutable |
77
|
|
|
*/ |
78
|
|
|
public function loadTime() |
79
|
|
|
{ |
80
|
|
|
return $this->loadTime; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return \DateTimeImmutable |
85
|
|
|
*/ |
86
|
|
|
public function unloadTime() |
87
|
|
|
{ |
88
|
|
|
return $this->unloadTime; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param Leg $other |
93
|
|
|
* @return bool |
94
|
|
|
*/ |
95
|
|
|
public function sameValueAs(Leg $other) |
96
|
|
|
{ |
97
|
|
|
if ($this->loadLocation() !== $other->loadLocation()) { |
98
|
|
|
return false; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
if ($this->unloadLocation() !== $other->unloadLocation()) { |
102
|
|
|
return false; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
if ($this->loadTime() != $other->loadTime()) { |
106
|
|
|
return false; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
if ($this->unloadTime() != $other->unloadTime()) { |
110
|
|
|
return false; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return true; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
} |
117
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..