GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PaymentInformation::setCreditCardNumber()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Magium\Magento\Actions\Checkout;
4
5
use Magium\AbstractConfigurableElement;
6
use Magium\Util\Configuration\ConfigurationCollector\DefaultPropertyCollector;
7
use Magium\Util\Configuration\StandardConfigurationProvider;
8
9
class PaymentInformation extends AbstractConfigurableElement
10
{
11
    const ACTION = 'Checkout\PaymentInformation';
12
13
    public $creditCardNumber;
14
    public $expiryYear;
15
    public $expiryMonth;
16
    public $cvv;
17
    public $type;
18
19
    public function __construct(StandardConfigurationProvider $configurationProvider, DefaultPropertyCollector $collector)
20
    {
21
        /*
22
         * Note: payment information is placed in this class instead of the payment step because I wanted to make
23
         * the payment easily configurable which is why this class extends AbstractConfigurableElement.  The payment
24
         * step class does not extend AbstractConfigurableElement (because it needs the constructor for dependency
25
         * injection) and so this class is here so payment can be globally configured.
26
         *
27
         * This way if you want to handle your own credit card you only have to configure this class
28
        */
29
30
        parent::__construct($configurationProvider, $collector);
31
        $this->setDefaults();
32
    }
33
34
35
    protected function setDefaults()
36
    {
37
        if (!$this->creditCardNumber) {
38
            $this->creditCardNumber = '4111111111111111';
39
        }
40
        if (!$this->expiryMonth) {
41
            $this->expiryMonth = '1';
42
        }
43
        if (!$this->expiryYear) {
44
            $this->expiryYear = date('Y', time() + (60 * 60 * 24 * 365 * 5));  // January plus 5 years
45
        }
46
        if (!$this->cvv) {
47
            $this->cvv = '123';
48
        }
49
        if (!$this->type) {
50
            $this->type = 'VI';
51
        }
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getCreditCardNumber()
58
    {
59
        return $this->creditCardNumber;
60
    }
61
62
    /**
63
     * @param string $creditCardNumber
64
     */
65
    public function setCreditCardNumber($creditCardNumber)
66
    {
67
        $this->creditCardNumber = $creditCardNumber;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getExpiryMonth()
74
    {
75
        return $this->expiryMonth;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getExpiryYear()
82
    {
83
        return $this->expiryYear;
84
    }
85
86
    /**
87
     * @param string $expiryDate
88
     */
89
    public function setExpiryDate($expiryDate)
90
    {
91
        $this->expiryDate = $expiryDate;
0 ignored issues
show
Documentation introduced by
The property expiryDate does not exist on object<Magium\Magento\Ac...out\PaymentInformation>. 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...
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getType()
98
    {
99
        return $this->type;
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    public function getCvv()
106
    {
107
        return $this->cvv;
108
    }
109
110
    /**
111
     * @param string $cvv
112
     */
113
    public function setCvv($cvv)
114
    {
115
        $this->cvv = $cvv;
116
    }
117
118
    /**
119
     * @param mixed $expiryMonth
120
     */
121
    public function setExpiryMonth($expiryMonth)
122
    {
123
        $this->expiryMonth = $expiryMonth;
124
    }
125
126
    /**
127
     * @param mixed $expiryYear
128
     */
129
    public function setExpiryYear($expiryYear)
130
    {
131
        $this->expiryYear = $expiryYear;
132
    }
133
134
    /**
135
     * @param mixed $type
136
     */
137
    public function setType($type)
138
    {
139
        $this->type = $type;
140
    }
141
142
143
144
}