DirectCreditPayment_TESTFAILURE   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 45
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A processPayment() 7 7 1
A getPaymentFormFields() 7 7 1
A getPaymentFormRequirements() 4 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
/**
4
 * Payment object representing a DirectCredit payment.
5
 * @author Nicolaas [at] sunnysideup.co.nz
6
 * @package payment
7
 */
8 View Code Duplication
class DirectCreditPayment extends EcommercePayment
0 ignored issues
show
Duplication introduced by
This class 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...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
11
    /**
12
     * Message shown before payment is made
13
     * @var String
14
     */
15
    private static $before_payment_message = "";
0 ignored issues
show
Unused Code introduced by
The property $before_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
16
17
    /**
18
     * Message shown after payment is made
19
     * @var String
20
     */
21
    private static $after_payment_message = "";
0 ignored issues
show
Unused Code introduced by
The property $after_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
22
23
    /**
24
     * Default Status for Payment
25
     * @var String
26
     */
27
    private static $default_status = "Pending";
0 ignored issues
show
Unused Code introduced by
The property $default_status is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
28
29
30
    /**
31
     * Process the DirectCredit payment method
32
     */
33
    public function processPayment($data, $form)
34
    {
35
        $this->Status = Config::inst()->get("DirectCreditPayment", "default_status");
0 ignored issues
show
Bug introduced by
The property Status does not seem to exist. Did you mean default_status?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
36
        $this->Message = Config::inst()->get("DirectCreditPayment", "after_payment_message");
0 ignored issues
show
Bug introduced by
The property Message does not seem to exist. Did you mean before_payment_message?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
37
        $this->write();
38
        return EcommercePayment_Success::create();
39
    }
40
41
    public function getPaymentFormFields()
42
    {
43
        return new FieldList(
44
            new LiteralField($this->ClassName.'_BeforeMessage', '<div id="'.$this->ClassName.'_BeforeMessage">' . Config::inst()->get("DirectCreditPayment", "before_payment_message") . '</div>'),
45
            new HiddenField($this->ClassName, $this->ClassName, 0)
46
        );
47
    }
48
49
    public function getPaymentFormRequirements()
50
    {
51
        return null;
52
    }
53
}
54
55 View Code Duplication
class DirectCreditPayment_ViaCreditCart extends EcommercePayment
0 ignored issues
show
Duplication introduced by
This class 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...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
56
{
57
58
    /**
59
     * Message shown before payment is made
60
     * @var String
61
     */
62
    private static $before_payment_message = "";
0 ignored issues
show
Unused Code introduced by
The property $before_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
63
64
    /**
65
     * Message shown after payment is made
66
     * @var String
67
     */
68
    private static $after_payment_message = "";
0 ignored issues
show
Unused Code introduced by
The property $after_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
69
70
    /**
71
     * Default Status for Payment
72
     * @var String
73
     */
74
    private static $default_status = "Pending";
0 ignored issues
show
Unused Code introduced by
The property $default_status is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
75
76
    /**
77
     * Process the DirectCredit payment method
78
     */
79
    public function processPayment($data, $form)
80
    {
81
        $this->Status = Config::inst()->get("DirectCreditPayment_ViaCreditCart", "default_status");
0 ignored issues
show
Bug introduced by
The property Status does not seem to exist. Did you mean default_status?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
82
        $this->Message = Config::inst()->get("DirectCreditPayment_ViaCreditCart", "after_payment_message");
0 ignored issues
show
Bug introduced by
The property Message does not seem to exist. Did you mean before_payment_message?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
83
        $this->write();
84
        return EcommercePayment_Success::create();
85
    }
86
87
    public function getPaymentFormFields()
88
    {
89
        return new FieldList(
90
            new LiteralField($this->ClassName.'_BeforeMessage', '<div id="'.$this->ClassName.'_BeforeMessage">' . Config::inst()->get("DirectCreditPayment_ViaCreditCart", "before_payment_message") . '</div>'),
91
            new HiddenField($this->ClassName, $this->ClassName, 0)
92
        );
93
    }
94
95
    public function getPaymentFormRequirements()
96
    {
97
        return null;
98
    }
99
}
100
101 View Code Duplication
class DirectCreditPayment_ViaCheque extends EcommercePayment
0 ignored issues
show
Duplication introduced by
This class 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...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
102
{
103
104
    /**
105
     * Message shown before payment is made
106
     * @var String
107
     */
108
    private static $before_payment_message = "";
0 ignored issues
show
Unused Code introduced by
The property $before_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
109
110
    /**
111
     * Message shown after payment is made
112
     * @var String
113
     */
114
    private static $after_payment_message = "";
0 ignored issues
show
Unused Code introduced by
The property $after_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
115
116
    /**
117
     * Default Status for Payment
118
     * @var String
119
     */
120
    private static $default_status = "Pending";
0 ignored issues
show
Unused Code introduced by
The property $default_status is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
121
122
    /**
123
     * Process the DirectCredit payment method
124
     */
125
    public function processPayment($data, $form)
126
    {
127
        $this->Status = Config::inst()->get("DirectCreditPayment_ViaCheque", "default_status");
0 ignored issues
show
Bug introduced by
The property Status does not seem to exist. Did you mean default_status?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
128
        $this->Message = Config::inst()->get("DirectCreditPayment_ViaCheque", "after_payment_message");
0 ignored issues
show
Bug introduced by
The property Message does not seem to exist. Did you mean before_payment_message?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
129
        $this->write();
130
        return EcommercePayment_Success::create();
131
    }
132
133
    public function getPaymentFormFields()
134
    {
135
        return new FieldList(
136
            new LiteralField($this->ClassName.'_BeforeMessage', '<div id="'.$this->ClassName.'_BeforeMessage">' . Config::inst()->get("DirectCreditPayment_ViaCheque", "before_payment_message") . '</div>'),
137
            new HiddenField($this->ClassName, $this->ClassName, 0)
138
        );
139
    }
140
141
    public function getPaymentFormRequirements()
142
    {
143
        return null;
144
    }
145
}
146
147 View Code Duplication
class DirectCreditPayment_TESTSUCCESS extends EcommercePayment
0 ignored issues
show
Duplication introduced by
This class 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...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
148
{
149
150
    /**
151
     * Message shown before payment is made
152
     * @var String
153
     */
154
    private static $before_payment_message = "This is for testing purposes only";
0 ignored issues
show
Unused Code introduced by
The property $before_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
155
156
    /**
157
     * Message shown after payment is made
158
     * @var String
159
     */
160
    private static $after_payment_message = "Payment is always successful";
0 ignored issues
show
Unused Code introduced by
The property $after_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
161
162
    /**
163
     * Default Status for Payment
164
     * @var String
165
     */
166
    private static $default_status = "Success";
0 ignored issues
show
Unused Code introduced by
The property $default_status is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
167
168
    /**
169
     * Process the DirectCredit payment method
170
     */
171
    public function processPayment($data, $form)
172
    {
173
        $this->Status = Config::inst()->get("DirectCreditPayment_TESTSUCCESS", "default_status");
0 ignored issues
show
Bug introduced by
The property Status does not seem to exist. Did you mean default_status?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
174
        $this->Message = Config::inst()->get("DirectCreditPayment_TESTSUCCESS", "after_payment_message");
0 ignored issues
show
Bug introduced by
The property Message does not seem to exist. Did you mean before_payment_message?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
175
        $this->write();
176
        return EcommercePayment_Success::create();
177
    }
178
179
    public function getPaymentFormFields()
180
    {
181
        return new FieldList(
182
            new LiteralField($this->ClassName.'_BeforeMessage', '<div id="'.$this->ClassName.'_BeforeMessage">' . Config::inst()->get("DirectCreditPayment_TESTSUCCESS", "before_payment_message") . '</div>'),
183
            new HiddenField($this->ClassName, $this->ClassName, 0)
184
        );
185
    }
186
187
    public function getPaymentFormRequirements()
188
    {
189
        return null;
190
    }
191
}
192
193
194 View Code Duplication
class DirectCreditPayment_TESTFAILURE extends EcommercePayment
0 ignored issues
show
Duplication introduced by
This class 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...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
195
{
196
197
    /**
198
     * Message shown before payment is made
199
     * @var String
200
     */
201
    private static $before_payment_message = "This is for testing purposes only";
0 ignored issues
show
Unused Code introduced by
The property $before_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
202
203
    /**
204
     * Message shown after payment is made
205
     * @var String
206
     */
207
    private static $after_payment_message = "Payment is always unsuccessful";
0 ignored issues
show
Unused Code introduced by
The property $after_payment_message is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
208
209
    /**
210
     * Default Status for Payment
211
     * @var String
212
     */
213
    private static $default_status = "Failure";
0 ignored issues
show
Unused Code introduced by
The property $default_status is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
214
215
    /**
216
     * Process the DirectCredit payment method
217
     */
218
    public function processPayment($data, $form)
219
    {
220
        $this->Status = Config::inst()->get("DirectCreditPayment_TESTFAILURE", "default_status");
0 ignored issues
show
Bug introduced by
The property Status does not seem to exist. Did you mean default_status?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
221
        $this->Message = Config::inst()->get("DirectCreditPayment_TESTFAILURE", "after_payment_message");
0 ignored issues
show
Bug introduced by
The property Message does not seem to exist. Did you mean before_payment_message?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
222
        $this->write();
223
        return EcommercePayment_Success::create();
224
    }
225
226
    public function getPaymentFormFields()
227
    {
228
        return new FieldList(
229
            new LiteralField($this->ClassName.'_BeforeMessage', '<div id="'.$this->ClassName.'_BeforeMessage">' . Config::inst()->get("DirectCreditPayment_TESTFAILURE", "before_payment_message") . '</div>'),
230
            new HiddenField($this->ClassName, $this->ClassName, 0)
231
        );
232
    }
233
234
    public function getPaymentFormRequirements()
235
    {
236
        return null;
237
    }
238
}
239