InStorePayment::getPaymentFormFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * Payment object representing an In Store Payment (order online and pick-up in store).
5
 * @author Nicolaas [at] sunnysideup.co.nz
6
 * @package payment
7
 */
8
class InStorePayment extends EcommercePayment
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...
9
{
10
    private static $custom_message_for_in_store_payment = "";
0 ignored issues
show
Unused Code introduced by
The property $custom_message_for_in_store_payment 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...
11
12
    /**
13
     * Process the In Store payment method
14
     */
15
    public function processPayment($data, $form)
16
    {
17
        $this->Status = 'Pending';
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<InStorePayment>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

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

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...
19
        $this->write();
20
        return EcommercePayment_Success::create();
21
    }
22
23
    public function getPaymentFormFields()
24
    {
25
        return new FieldList(
26
            new HiddenField("InStore", "InStore", 0)
27
        );
28
    }
29
30
    public function getPaymentFormRequirements()
31
    {
32
        return null;
33
    }
34
}
35