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

SingleCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
A getContext() 0 4 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
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Baleen\Migrations\Service\Command\Migrate\Single;
21
22
use Baleen\Migrations\Migration\OptionsInterface;
23
use Baleen\Migrations\Service\Command\DomainCommandInterface;
24
use Baleen\Migrations\Service\Command\HasOptionsTrait;
25
use Baleen\Migrations\Service\Command\HasVersionRepositoryTrait;
26
use Baleen\Migrations\Service\Command\Migrate\HasTargetTrait;
27
use Baleen\Migrations\Shared\Event\Context\CollectionContext;
28
use Baleen\Migrations\Shared\Event\Context\CollectionContextInterface;
29
use Baleen\Migrations\Shared\Event\Progress;
30
use Baleen\Migrations\Version\Repository\VersionRepositoryInterface;
31
use Baleen\Migrations\Version\VersionInterface;
32
33
/**
34
 * Class SingleCommand
35
 *
36
 * @author Gabriel Somoza <[email protected]>
37
 */
38
final class SingleCommand implements DomainCommandInterface
39
{
40
    use HasTargetTrait;
41
    use HasOptionsTrait;
42
    use HasVersionRepositoryTrait;
43
44
    /** @var CollectionContextInterface */
45
    private $context;
46
47
    /**
48
     * CollectionCommand constructor.
49
     *
50
     * @param VersionInterface $target
51
     * @param OptionsInterface $options
52
     * @param VersionRepositoryInterface $versionRepository
53
     * @param CollectionContextInterface $context
0 ignored issues
show
Documentation introduced by
Should the type for parameter $context not be null|CollectionContextInterface?

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...
54
     */
55 2
    public function __construct(
56
        VersionInterface $target,
57
        OptionsInterface $options,
58
        VersionRepositoryInterface $versionRepository,
59
        CollectionContextInterface $context = null
60
    ) {
61 2
        if (null === $context) {
62 2
            $context = new CollectionContext(new Progress(1, 1));
63 2
        }
64
65 2
        $this->context = $context;
66 2
        $this->setTarget($target);
67 2
        $this->setOptions($options);
68 2
        $this->setVersionRepository($versionRepository);
69 2
    }
70
71
    /**
72
     * @return CollectionContextInterface
73
     */
74 2
    public function getContext()
75
    {
76 2
        return $this->context;
77
    }
78
}
79