Completed
Push — master ( 6343d0...45320b )
by Bernhard
06:10
created

ModuleFile10To20Migration   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 61.11 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 61.11%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 22
loc 36
ccs 11
cts 18
cp 0.6111
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSourceVersion() 0 4 1
A getTargetVersion() 0 4 1
A up() 11 11 2
A down() 11 11 2

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
/*
4
 * This file is part of the webmozart/json package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Manager\Module\Migration;
13
14
use Puli\Manager\Module\ModuleFileConverter;
15
use stdClass;
16
use Webmozart\Json\Migration\JsonMigration;
17
18
/**
19
 * @since  1.0
20
 *
21
 * @author Bernhard Schussek <[email protected]>
22
 */
23
class ModuleFile10To20Migration implements JsonMigration
24
{
25 26
    public function getSourceVersion()
26
    {
27 26
        return '1.0';
28
    }
29
30 26
    public function getTargetVersion()
31
    {
32 26
        return '2.0';
33
    }
34
35 26 View Code Duplication
    public function up(stdClass $data)
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...
36
    {
37 26
        $data->{'$schema'} = sprintf(ModuleFileConverter::SCHEMA, '2.0');
38
39 26
        unset($data->version);
40
41 26
        if (isset($data->packages)) {
42 26
            $data->modules = $data->packages;
43 26
            unset($data->packages);
44
        }
45 26
    }
46
47 View Code Duplication
    public function down(stdClass $data)
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...
48
    {
49
        unset($data->{'$schema'});
50
51
        $data->version = '1.0';
52
53
        if (isset($data->modules)) {
54
            $data->packages = $data->modules;
55
            unset($data->modules);
56
        }
57
    }
58
}
59