Completed
Pull Request — master (#15)
by Gabriel
03:36
created

CollectionEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 75
ccs 17
cts 17
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getOptions() 0 4 1
A getCollection() 0 4 1
A getTarget() 0 4 1
A getAdditionalPayload() 0 8 1
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\Shared\Collection\CollectionInterface;
24
use Baleen\Migrations\Shared\Event\AbstractDomainEvent;
25
use Baleen\Migrations\Version\VersionInterface;
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 VersionInterface
47
     */
48
    private $target;
49
50
    /**
51
     * CollectionEvent constructor.
52
     *
53
     * @param VersionInterface $target
54
     * @param OptionsInterface $options
55
     * @param CollectionInterface $collection
56
     * @param DateTime $createdOn
0 ignored issues
show
Documentation introduced by
Should the type for parameter $createdOn not be null|DateTime?

This check looks for @param annotations 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.

Loading history...
57
     */
58 22
    public function __construct(
59
        VersionInterface $target,
60
        OptionsInterface $options,
61
        CollectionInterface $collection,
62
        DateTime $createdOn = null
63
    ) {
64 22
        $this->options = $options;
65 22
        $this->target = $target;
66 22
        $this->collection = $collection;
67 22
        parent::__construct($createdOn);
68 22
    }
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 2
    final public function getCollection()
82
    {
83 2
        return $this->collection;
84
    }
85
86
    /**
87
     * @return VersionInterface
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