Completed
Push — master ( 3a7943...bccb03 )
by Nicolaas
03:04
created

EcommercePayment_TestFailure::i18n_plural_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
/**
5
 * Payment object representing a TEST = FAILURE.
6
 */
7
class EcommercePayment_TestFailure extends EcommercePayment_Test
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...
8
{
9
10
11
    /**
12
     * standard SS variable.
13
     *
14
     * @Var String
15
     */
16
    private static $singular_name = 'Ecommerce Test Failure Payment';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $singular_name 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...
17
    public function i18n_singular_name()
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...
18
    {
19
        return $this->Config()->get('singular_name');
20
    }
21
22
    /**
23
     * standard SS variable.
24
     *
25
     * @Var String
26
     */
27
    private static $plural_name = 'Ecommerce Test Failuer Payments';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $plural_name 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
    public function i18n_plural_name()
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...
29
    {
30
        return $this->Config()->get('plural_name');
31
    }
32
33
    /**
34
     * @param array     $data The form request data - see OrderForm
35
     * @param OrderForm $form The form object submitted on
36
     *
37
     * @return EcommercePayment_Result
38
     */
39
    public function processPayment($data, $form)
40
    {
41
        $this->Status = 'Failure';
0 ignored issues
show
Documentation introduced by
The property Status does not exist on object<EcommercePayment_TestFailure>. 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...
42
        $this->Message = '<div>PAYMENT TEST: FAILURE</div>';
0 ignored issues
show
Documentation introduced by
The property Message does not exist on object<EcommercePayment_TestFailure>. 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...
43
        $this->write();
44
45
        return new EcommercePayment_Failure();
46
    }
47
48
    public function getPaymentFormFields()
49
    {
50
        return new FieldList(
51
            new LiteralField('SuccessBlurb', '<div>FAILURE PAYMENT TEST</div>')
52
        );
53
    }
54
}
55