Completed
Branch ddd-changes (96d3bc)
by Gabriel
05:08
created

Definition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 26.83 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 2
A getId() 0 4 1
A getMigration() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Migration\Repository\Mapper;
1 ignored issue
show
Coding Style introduced by
There must be one blank line after the namespace declaration
Loading history...
21
use Baleen\Migrations\Migration\MigrationInterface;
22
use Baleen\Migrations\Shared\ValueObjectInterface;
23
use Baleen\Migrations\Version\VersionId;
24
25
/**
26
 * Class Definition
27
 *
28
 * @author Gabriel Somoza <[email protected]>
29
 */
30
final class Definition implements DefinitionInterface
31
{
32
    /** @var VersionId */
33
    private $id;
34
35
    /** @var MigrationInterface */
36
    private $migration;
37
38
    /**
39
     * Definition constructor.
40
     * @param MigrationInterface $migration
41
     * @param null|string|ValueObjectInterface $id Overrides the ID for the migration with the specified ID
42
     */
43 8 View Code Duplication
    public function __construct(MigrationInterface $migration, $id = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45 8
        if (null === $id) {
46 7
            $id = VersionId::fromMigration($migration);
47 7
        } else {
48 1
            $id = new VersionId((string) $id);
49
        }
50 8
        $this->id = $id;
51
52 8
        $this->migration = $migration;
53 8
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58 3
    public function getId()
59
    {
60 3
        return $this->id;
61
    }
62
63
    /**
64
     * @return MigrationInterface
65
     */
66 2
    public function getMigration()
67
    {
68 2
        return $this->migration;
69
    }
70
}
71