PickUpOrDeliveryModifier_Form   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B processOrderModifier() 0 20 6
1
<?php
2
3
4
class PickUpOrDeliveryModifier_Form extends OrderModifierForm
0 ignored issues
show
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...
5
{
6
    public function processOrderModifier($data, $form = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Unused Code introduced by
The parameter $form is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
7
    {
8
        if (isset($data['PickupOrDeliveryType'])) {
9
            $newOption = intval($data['PickupOrDeliveryType']);
10
            $newOptionObj = PickUpOrDeliveryModifierOptions::get()->byID($newOption);
11
            if ($newOptionObj) {
12
                $order = ShoppingCart::current_order();
13
                if ($order) {
14
                    if ($modifiers = $order->Modifiers("PickUpOrDeliveryModifier")) {
15
                        foreach ($modifiers as $modifier) {
16
                            $modifier->setOption($newOption);
17
                            $modifier->runUpdate();
18
                        }
19
                        return ShoppingCart::singleton()->setMessageAndReturn(_t("PickUpOrDeliveryModifier.UPDATED", "Delivery option updated"), "good");
20
                    }
21
                }
22
            }
23
        }
24
        return ShoppingCart::singleton()->setMessageAndReturn(_t("PickUpOrDeliveryModifier.UPDATED", "Delivery option could NOT be updated"), "bad");
25
    }
26
}
27