| 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 getThreeDS2DataConstraints() |
||
| 98 | { |
||
| 99 | return new Assert\Collection([ |
||
| 100 | 'notification_url' => $this->buildElement('string', 1), |
||
| 101 | 'browser_info' => $this->getBrowserInfoConstraints(), |
||
| 102 | 'billing_address' => $this->getAdressConstraints('billingAddress'), |
||
| 103 | 'delivery_address' => $this->getAdressConstraints('deliveryAddress'), |
||
| 104 | 'cardholder_info' => $this->getCardHolderInfoConstraints(), |
||
| 105 | ]); |
||
| 106 | } |
||
| 107 | |||
| 108 | private function getBrowserInfoConstraints() |
||
| 109 | { |
||
| 110 | return new Assert\Collection([ |
||
| 111 | 'accept_header' => $this->buildElement('string', 1), |
||
| 112 | 'browser_language' => $this->buildElement('string', 1), |
||
| 113 | 'screen_width' => $this->buildElement('integer', 1), |
||
| 114 | 'screen_height' => $this->buildElement('integer', 1), |
||
| 115 | 'challenge_window_size' => $this->buildElement('string', 1), |
||
| 116 | 'user_agent' => $this->buildElement('string', 1), |
||
| 117 | 'color_depth' => $this->buildElement('integer', 1), |
||
| 118 | 'time_zone' => $this->buildElement('integer', 1), |
||
| 119 | 'ip_address' => $this->buildElement('string'), |
||
| 120 | 'javascript_enabled' => $this->buildElement('bool'), |
||
| 121 | 'java_enabled' => $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]), |
||
| 133 | 'postal_code' => $this->buildElement('string', 1, ['max'=>16]), |
||
| 134 | 'state' => $this->buildElement('string', 0, ['max'=>14]), |
||
| 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 | |||
| 169 |