Issues (468)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

BraintreeForm.php (244 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace tuyakhov\braintree;
3
4
use yii\base\InvalidCallException;
5
use yii\base\Model;
6
use yii\base\ModelEvent;
7
8
class BraintreeForm extends Model
9
{
10
11
    public $amount;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
12
    public $orderId;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
13
    public $paymentMethodToken;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
14
15
    public $creditCard_number;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "creditCard_number" is not in valid camel caps format
Loading history...
16
    public $creditCard_cvv;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "creditCard_cvv" is not in valid camel caps format
Loading history...
17
    public $creditCard_expirationMonth;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "creditCard_expirationMonth" is not in valid camel caps format
Loading history...
18
    public $creditCard_expirationYear;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "creditCard_expirationYear" is not in valid camel caps format
Loading history...
19
    public $creditCard_expirationDate;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "creditCard_expirationDate" is not in valid camel caps format
Loading history...
20
    public $creditCard_name;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "creditCard_name" is not in valid camel caps format
Loading history...
21
22
    public $customer_firstName;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "customer_firstName" is not in valid camel caps format
Loading history...
23
    public $customer_lastName;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "customer_lastName" is not in valid camel caps format
Loading history...
24
    public $customer_company;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "customer_company" is not in valid camel caps format
Loading history...
25
    public $customer_phone;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "customer_phone" is not in valid camel caps format
Loading history...
26
    public $customer_fax;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "customer_fax" is not in valid camel caps format
Loading history...
27
    public $customer_website;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "customer_website" is not in valid camel caps format
Loading history...
28
    public $customer_email;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "customer_email" is not in valid camel caps format
Loading history...
29
30
    public $billing_firstName;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_firstName" is not in valid camel caps format
Loading history...
31
    public $billing_lastName;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_lastName" is not in valid camel caps format
Loading history...
32
    public $billing_company;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_company" is not in valid camel caps format
Loading history...
33
    public $billing_streetAddress;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_streetAddress" is not in valid camel caps format
Loading history...
34
    public $billing_extendedAddress;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_extendedAddress" is not in valid camel caps format
Loading history...
35
    public $billing_locality;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_locality" is not in valid camel caps format
Loading history...
36
    public $billing_region;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_region" is not in valid camel caps format
Loading history...
37
    public $billing_postalCode;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_postalCode" is not in valid camel caps format
Loading history...
38
    public $billing_countryCodeAlpha2;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "billing_countryCodeAlpha2" is not in valid camel caps format
Loading history...
39
40
    public $shipping_firstName;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_firstName" is not in valid camel caps format
Loading history...
41
    public $shipping_lastName;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_lastName" is not in valid camel caps format
Loading history...
42
    public $shipping_company;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_company" is not in valid camel caps format
Loading history...
43
    public $shipping_streetAddress;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_streetAddress" is not in valid camel caps format
Loading history...
44
    public $shipping_extendedAddress;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_extendedAddress" is not in valid camel caps format
Loading history...
45
    public $shipping_locality;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_locality" is not in valid camel caps format
Loading history...
46
    public $shipping_region;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_region" is not in valid camel caps format
Loading history...
47
    public $shipping_postalCode;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_postalCode" is not in valid camel caps format
Loading history...
48
    public $shipping_countryCodeAlpha2;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Member variable "shipping_countryCodeAlpha2" is not in valid camel caps format
Loading history...
49
50
    public $customerId;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
51
52
    public function rules()
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
53
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
54
        return [
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
55
            [['customerId', 'creditCard_number', 'creditCard_cvv', 'creditCard_expirationDate'], 'required', 'on' => 'creditCard'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
56
            [['customerId'], 'required', 'on' => 'address'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
57
            [['customer_firstName', 'customer_lastName'], 'required', 'on' => 'customer'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
58
            [['amount', 'creditCard_number', 'creditCard_cvv', 'creditCard_expirationDate'], 'required', 'on' => 'sale'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
59
            [['amount', 'paymentMethodToken'], 'required', 'on' => 'saleFromVault'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
60
            [['amount'], 'double'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
61
            [['customer_email'], 'email'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
62
            [['creditCard_expirationMonth',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
63
                'creditCard_expirationYear',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
64
                'creditCard_expirationDate',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
65
                'customer_firstName',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
66
                'customer_lastName',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
67
                'customer_company',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
68
                'customer_phone',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
69
                'customer_fax',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
70
                'customer_website',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
71
                'billing_firstName',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
72
                'billing_lastName',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
73
                'billing_company',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
74
                'billing_streetAddress',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
75
                'billing_extendedAddress',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
76
                'billing_locality',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
77
                'billing_region',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
78
                'billing_postalCode',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
79
                'billing_countryCodeAlpha2',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
80
                'shipping_firstName',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
81
                'shipping_lastName',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
82
                'shipping_company',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
83
                'shipping_streetAddress',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
84
                'shipping_extendedAddress',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
85
                'shipping_locality',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
86
                'shipping_region',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
87
                'shipping_postalCode',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
88
                'shipping_countryCodeAlpha2'], 'safe'],
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
89
        ];
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
90
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
91
92
    public function attributeLabels()
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
93
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
94
        return [
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
95
            'amount' => 'Amount($)',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
96
            'orderId' => 'Order ID',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
97
            'creditCard_number' => 'Credit Card Number',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
98
            'creditCard_cvv' => 'Security Code',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
99
            'creditCard_expirationMonth' => 'Expiration Month (MM)',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
100
            'creditCard_expirationYear' => 'Expiration Year (YYYY)',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
101
            'creditCard_expirationDate' => 'Expiration Date (MM/YYYY)',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
102
            'creditCard_name' => 'Name on Card',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
103
            'customer_firstName' => 'First Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
104
            'customer_lastName' => 'Last Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
105
            'customer_company' => 'Company Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
106
            'customer_phone' => 'Phone Number',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
107
            'customer_fax' => 'Fax Number',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
108
            'customer_website' => 'Website',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
109
            'customer_email' => 'Email',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
110
            'billing_firstName' => 'First Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
111
            'billing_lastName' => 'Last Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
112
            'billing_company' => 'Company Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
113
            'billing_streetAddress' => 'Address',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
114
            'billing_extendedAddress' => 'Address',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
115
            'billing_locality' => 'City/Locality',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
116
            'billing_region' => 'State/Region',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
117
            'billing_postalCode' => 'Zip/Postal Code',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
118
            'billing_countryCodeAlpha2' => 'Country',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
119
            'shipping_firstName' => 'First Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
120
            'shipping_lastName' => 'Last Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
121
            'shipping_company' => 'Company Name',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
122
            'shipping_streetAddress' => 'Address',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
123
            'shipping_extendedAddress' => 'Address',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
124
            'shipping_locality' => 'City/Locality',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
125
            'shipping_region' => 'State/Region',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
126
            'shipping_postalCode' => 'Zip/Postal Code',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
127
            'shipping_countryCodeAlpha2' => 'Country',
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
128
        ];
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
129
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
130
131
    public function getValuesFromAttributes()
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
132
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
133
        $values = array();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
134
        foreach ($this->attributes as $key => $val) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
135
            if (!is_object($val) && !is_null($val) && strlen($val) > 0) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
136
                if (strpos($key, '_') === false) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
137
                    $values[$key] = $val;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
138
                } else {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
139
                    $pieces = explode('_', $key);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
Equals sign not aligned with surrounding assignments; expected 25 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
140
                    $values[$pieces[0]][$pieces[1]] = $val;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
141
                }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
142
            }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
143
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
144
        return $values;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
145
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
146
147
    public function send()
0 ignored issues
show
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...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
148
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
149
        \Yii::$app->get('braintree')->getOptions($this->getValuesFromAttributes());
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
150
        $scenario = $this->getScenario();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
151
        return $this->$scenario();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
152
153
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
154
155 View Code Duplication
    public function sale()
0 ignored issues
show
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...
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...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
156
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
157
        $return = \Yii::$app->get('braintree')->singleCharge();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
158
        if ($return['status'] === false) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
159
            $this->addErrorFromResponse($return['result']);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
160
            return false;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
161
        } else {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
162
            return $return;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
163
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
164
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
165
166 View Code Duplication
    public function saleFromVault()
0 ignored issues
show
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...
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...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
167
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
168
        $return = \Yii::$app->get('braintree')->singleCharge();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
169
        if ($return['status'] === false) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
170
            $this->addErrorFromResponse($return['result']);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
171
            return false;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
172
        } else {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
173
            return $return;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
174
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
175
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
176
177 View Code Duplication
    public function customer()
0 ignored issues
show
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...
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...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
178
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
179
        $return = \Yii::$app->get('braintree')->saveCustomer();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
180
        if ($return['status'] === false) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
181
            $this->addErrorFromResponse($return['result']);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
182
            return false;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
183
        } else {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
184
            return $return;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
185
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
186
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
187
188 View Code Duplication
    public function creditCard()
0 ignored issues
show
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...
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...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
189
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
190
        $return = \Yii::$app->get('braintree')->saveCreditCard();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
191
        if ($return['status'] === false) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
192
            $this->addErrorFromResponse($return['result']);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
193
            return false;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
194
        } else {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
195
            return $return;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
196
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
197
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
198
199 View Code Duplication
    public function address()
0 ignored issues
show
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...
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...
Tabs must be used to indent lines; spaces are not allowed
Loading history...
200
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
201
        $return = \Yii::$app->get('braintree')->saveAddress();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
202
        if ($return['status'] === false) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
203
            $this->addErrorFromResponse($return['result']);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
204
            return false;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
205
        } else {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
206
            return $return;
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
207
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
208
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
209
210
    /**
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
211
     * This add error from braintree response.
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
212
     * @param $result \Braintree_Result_Error
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
213
     */
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
214
    public function addErrorFromResponse($result)
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
215
    {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
216
        $values = $this->getValuesFromAttributes();
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
217
        if (!empty($result->errors)) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
218
            foreach (array_keys($values) as $key) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
219
                $keyErrors = $result->errors->forKey($key);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
220
                if (isset($keyErrors)) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
221
                    foreach ($keyErrors->shallowAll() as $error) {
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
222
                        $this->addError(($key . '_' . $error->attribute), $error->message);
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
223
                    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
224
                }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
225
            }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
226
        }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
227
    }
0 ignored issues
show
Tabs must be used to indent lines; spaces are not allowed
Loading history...
228
229
}