Completed
Push — master ( 341936...178071 )
by Florian
03:31
created

UpgradeData   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 121
Duplicated Lines 66.12 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 80
loc 121
c 0
b 0
f 0
wmc 13
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
F upgrade() 80 93 12

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
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2016 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Setup;
28
29
use Magento\Framework\Setup\ModuleContextInterface;
30
use Magento\Framework\Setup\ModuleDataSetupInterface;
31
use Magento\Framework\Setup\UpgradeDataInterface;
32
use Magento\Sales\Setup\SalesSetupFactory;
33
34
/**
35
 * Class UpgradeData
36
 */
37
class UpgradeData implements UpgradeDataInterface
38
{
39
    /**
40
     * Sales setup factory
41
     *
42
     * @var SalesSetupFactory
43
     */
44
    protected $salesSetupFactory;
45
46
    /**
47
     * Constructor
48
     *
49
     * @param SalesSetupFactory $salesSetupFactory
50
     */
51
    public function __construct(SalesSetupFactory $salesSetupFactory)
52
    {
53
        $this->salesSetupFactory = $salesSetupFactory;
54
    }
55
56
    /**
57
     * Upgrade method
58
     *
59
     * @param  ModuleDataSetupInterface $setup
60
     * @param  ModuleContextInterface   $context
61
     * @return void
62
     */
63
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
64
    {
65
        $setup->startSetup();
66 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_reference')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
67
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
68
            $salesInstaller->addAttribute(
69
                'order',
70
                'payone_clearing_reference',
71
                ['type' => 'varchar', 'length' => 64, 'default' => '']
72
            );
73
        }
74 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_workorder_id')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
75
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
76
            $salesInstaller->addAttribute(
77
                'order',
78
                'payone_workorder_id',
79
                ['type' => 'varchar', 'length' => 64, 'default' => '']
80
            );
81
        }
82
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_installment_duration')) {
83
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
84
            $salesInstaller->addAttribute(
85
                'order',
86
                'payone_installment_duration',
87
                ['type' => 'integer', 'length' => null]
88
            );
89
        }
90 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankaccountholder')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
91
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
92
            $salesInstaller->addAttribute(
93
                'order',
94
                'payone_clearing_bankaccountholder',
95
                ['type' => 'varchar', 'length' => 64, 'default' => '']
96
            );
97
        }
98 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankcountry')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
99
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
100
            $salesInstaller->addAttribute(
101
                'order',
102
                'payone_clearing_bankcountry',
103
                ['type' => 'varchar', 'length' => 2, 'default' => '']
104
            );
105
        }
106 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankaccount')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
107
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
108
            $salesInstaller->addAttribute(
109
                'order',
110
                'payone_clearing_bankaccount',
111
                ['type' => 'varchar', 'length' => 32, 'default' => '']
112
            );
113
        }
114 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankcode')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
115
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
116
            $salesInstaller->addAttribute(
117
                'order',
118
                'payone_clearing_bankcode',
119
                ['type' => 'varchar', 'length' => 32, 'default' => '']
120
            );
121
        }
122 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankiban')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
123
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
124
            $salesInstaller->addAttribute(
125
                'order',
126
                'payone_clearing_bankiban',
127
                ['type' => 'varchar', 'length' => 64, 'default' => '']
128
            );
129
        }
130 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankbic')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
131
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
132
            $salesInstaller->addAttribute(
133
                'order',
134
                'payone_clearing_bankbic',
135
                ['type' => 'varchar', 'length' => 32, 'default' => '']
136
            );
137
        }
138 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankcity')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
139
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
140
            $salesInstaller->addAttribute(
141
                'order',
142
                'payone_clearing_bankcity',
143
                ['type' => 'varchar', 'length' => 64, 'default' => '']
144
            );
145
        }
146 View Code Duplication
        if (!$setup->getConnection()->tableColumnExists($setup->getTable('sales_order'), 'payone_clearing_bankname')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
147
            $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
148
            $salesInstaller->addAttribute(
149
                'order',
150
                'payone_clearing_bankname',
151
                ['type' => 'varchar', 'length' => 64, 'default' => '']
152
            );
153
        }
154
        $setup->endSetup();
155
    }
156
157
}
158