Conditions | 3 |
Paths | 3 |
Total Lines | 56 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
93 | ) |
||
94 | ); |
||
95 | } |
||
96 | |||
97 | private function getTrheeDS2DataConstraints() |
||
98 | { |
||
99 | return new Assert\Collection([ |
||
100 | 'notificationUrl' => $this->buildElement('string', 1), |
||
101 | 'browserInfo' => $this->getBrowserInfoConstraints(), |
||
102 | 'billingAddress' => $this->getAdressConstraints('billingAddress'), |
||
103 | 'deliveryAddress' => $this->getAdressConstraints('deliveryAddress'), |
||
104 | 'cardHolderInfo' => $this->getCardHolderInfoConstraints(), |
||
105 | ]); |
||
106 | } |
||
107 | |||
108 | private function getBrowserInfoConstraints() |
||
109 | { |
||
110 | return new Assert\Collection([ |
||
111 | 'acceptHeader' => $this->buildElement('string', 1), |
||
112 | 'browserLanguage' => $this->buildElement('string', 1), // TODO should implement standard IETF BCP 47 (https://tools.ietf.org/html/bcp47) |
||
113 | 'screenWidth' => $this->buildElement('integer', 1), |
||
114 | 'screenHeight' => $this->buildElement('integer', 1), |
||
115 | 'challengeWindowSize' => $this->buildElement('string', 1), |
||
116 | 'userAgent' => $this->buildElement('string', 1), |
||
117 | 'colorDepth' => $this->buildElement('integer', 1), |
||
118 | 'timeZone' => $this->buildElement('integer', 1), |
||
119 | 'ipAddress' => $this->buildElement('string'), |
||
120 | 'javaEnabled' => $this->buildElement('bool'), |
||
121 | 'javascriptEnabled' => $this->buildElement('bool'), |
||
122 | ]); |
||
123 | } |
||
124 | |||
125 | private function getAdressConstraints() |
||
126 | { |
||
127 | return new Assert\Collection([ |
||
128 | 'address_line1' => $this->buildElement('string', 1, ['max'=>50]), |
||
129 | 'address_line2' => $this->buildElement('string', 1, ['max'=>50]), |
||
130 | 'address_line3' => $this->buildElement('string', 0, ['max'=>50]), |
||
131 | 'city' => $this->buildElement('string', 1, ['max'=>50]), |
||
132 | 'country' => $this->buildElement('string', 1, ['max'=>10]), // TODO ISO 3166-1 alpha-2 country code. |
||
133 | 'postal_code' => $this->buildElement('string', 1, ['max'=>16]), |
||
134 | 'state' => $this->buildElement('string', 0, ['max'=>14]), // TODO country subdivision code defined in ISO 3166-2 |
||
135 | ]); |
||
136 | } |
||
137 | |||
138 | private function getCardHolderInfoConstraints() |
||
139 | { |
||
140 | return new Assert\Collection([ |
||
141 | 'email_address' => new Assert\Optional([ |
||
142 | new Assert\Email(['mode'=>'loose']) |
||
143 | ]), |
||
144 | 'mobile_phone_number' => $this->buildElement('string'), |
||
145 | 'work_phone_number' => $this->buildElement('string'), |
||
146 | 'home_phone_number' => $this->buildElement('string'), |
||
147 | ]); |
||
148 | } |
||
149 | |||
165 |