saveAddressAndCreateSubscription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
4
class RepeatOrders_OrderFormAddressExtension extends Extension
5
{
6
7
    public function updateOrderFormAddress(&$form)
8
    {
9
        $nextButton = new FormAction('saveAddressAndSkipSubscriptionStep', 'Confirm and Pay');
10
        $nextButton->addExtraClass('next');
11
        $subsButton = new FormAction('saveAddressAndCreateSubscription', 'Create Subscription');
12
        $subsButton->addExtraClass('next');
13
        $actions = FieldList::create($subsButton, $nextButton);
14
        $form->setActions($actions);
15
    }
16
17
18 View Code Duplication
    public function saveAddressAndSkipSubscriptionStep(array $data, Form $form, SS_HTTPRequest $request)
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...
19
    {
20
        $this->owner->saveAddressDetails($data, $form, $request);
21
22
        $nextStepLink = CheckoutPage::find_next_step_link('orderformsubscription');
23
        $this->owner->controller->redirect($nextStepLink);
0 ignored issues
show
Bug introduced by
The property controller does not seem to exist in SS_Object.

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...
24
25
        return true;
26
    }
27
28 View Code Duplication
    public function saveAddressAndCreateSubscription(array $data, Form $form, SS_HTTPRequest $request)
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...
29
    {
30
        $this->owner->saveAddressDetails($data, $form, $request);
31
32
        $nextStepLink = CheckoutPage::find_next_step_link('orderformaddress');
33
        $this->owner->controller->redirect($nextStepLink);
0 ignored issues
show
Bug introduced by
The property controller does not seem to exist in SS_Object.

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...
34
35
        return true;
36
    }
37
}
38