|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the MIT license. For more information, see |
|
17
|
|
|
* <https://github.com/baleen/migrations>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Baleen\Migrations\Service\Runner\Event\Collection; |
|
21
|
|
|
|
|
22
|
|
|
use Baleen\Migrations\Migration\OptionsInterface; |
|
23
|
|
|
use Baleen\Migrations\Common\Collection\CollectionInterface; |
|
24
|
|
|
use Baleen\Migrations\Common\Event\AbstractDomainEvent; |
|
25
|
|
|
use Baleen\Migrations\Delta\DeltaInterface; |
|
26
|
|
|
use DateTime; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class CollectionEvent. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Gabriel Somoza <[email protected]> |
|
32
|
|
|
*/ |
|
33
|
|
|
class CollectionEvent extends AbstractDomainEvent |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var CollectionInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
private $collection; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var OptionsInterface |
|
42
|
|
|
*/ |
|
43
|
|
|
private $options; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var DeltaInterface |
|
47
|
|
|
*/ |
|
48
|
|
|
private $target; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* CollectionEvent constructor. |
|
52
|
|
|
* |
|
53
|
|
|
* @param DeltaInterface $target |
|
54
|
|
|
* @param OptionsInterface $options |
|
55
|
|
|
* @param CollectionInterface $collection |
|
56
|
|
|
* @param DateTime $createdOn |
|
|
|
|
|
|
57
|
|
|
*/ |
|
58
|
23 |
|
public function __construct( |
|
59
|
|
|
DeltaInterface $target, |
|
60
|
|
|
OptionsInterface $options, |
|
61
|
|
|
CollectionInterface $collection, |
|
62
|
|
|
DateTime $createdOn = null |
|
63
|
|
|
) { |
|
64
|
23 |
|
$this->options = $options; |
|
65
|
23 |
|
$this->target = $target; |
|
66
|
23 |
|
$this->collection = $collection; |
|
67
|
23 |
|
parent::__construct($createdOn); |
|
68
|
23 |
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return OptionsInterface |
|
72
|
|
|
*/ |
|
73
|
2 |
|
final public function getOptions() |
|
74
|
|
|
{ |
|
75
|
2 |
|
return $this->options; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return CollectionInterface |
|
80
|
|
|
*/ |
|
81
|
3 |
|
final public function getCollection() |
|
82
|
|
|
{ |
|
83
|
3 |
|
return $this->collection; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return DeltaInterface |
|
88
|
|
|
*/ |
|
89
|
2 |
|
final public function getTarget() |
|
90
|
|
|
{ |
|
91
|
2 |
|
return $this->target; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Returns the event getPayload |
|
96
|
|
|
* |
|
97
|
|
|
* @return array |
|
98
|
|
|
*/ |
|
99
|
1 |
|
protected function getAdditionalPayload() |
|
100
|
|
|
{ |
|
101
|
|
|
return [ |
|
102
|
1 |
|
'target' => $this->getTarget(), |
|
103
|
1 |
|
'options' => $this->getOptions(), |
|
104
|
1 |
|
'collection' => $this->getCollection(), |
|
105
|
1 |
|
]; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.