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 | throw new \InvalidArgumentException( |
||
97 | sprintf( |
||
98 | 'Payment instrument for payment method "%s" is not expected', |
||
99 | $method |
||
100 | ) |
||
101 | ); |
||
102 | } |
||
103 | |||
104 | private function getThreeDS2DataConstraints() |
||
105 | { |
||
106 | return new Assert\Collection([ |
||
107 | 'notification_url' => $this->buildElement('string', 1), |
||
108 | 'browser_info' => $this->getBrowserInfoConstraints(), |
||
109 | 'billing_address' => new Assert\Optional( |
||
110 | $this->getAdressConstraints() |
||
111 | ), |
||
112 | 'delivery_address' => new Assert\Optional( |
||
113 | $this->getAdressConstraints() |
||
114 | ), |
||
115 | 'cardholder_info' => new Assert\Optional( |
||
116 | $this->getCardHolderInfoConstraints() |
||
117 | ), |
||
118 | ]); |
||
119 | } |
||
120 | |||
121 | private function getBrowserInfoConstraints() |
||
122 | { |
||
123 | return new Assert\Collection([ |
||
124 | 'accept_header' => $this->buildElement('string', 1), |
||
125 | 'browser_language' => $this->buildElement('string', 1), |
||
126 | 'screen_width' => $this->buildElement('integer', 1), |
||
127 | 'screen_height' => $this->buildElement('integer', 1), |
||
128 | 'challenge_window_size' => $this->buildElement('string', 1), |
||
129 | 'user_agent' => $this->buildElement('string', 1), |
||
130 | 'color_depth' => $this->buildElement('integer', 1), |
||
131 | 'time_zone' => $this->buildElement('integer', 1), |
||
132 | 'ip_address' => new Assert\Optional($this->buildElement('string')), |
||
133 | 'javascript_enabled' => new Assert\Optional($this->buildElement('bool')), |
||
134 | 'java_enabled' => new Assert\Optional($this->buildElement('bool')), |
||
135 | ]); |
||
136 | } |
||
137 | |||
138 | private function getAdressConstraints() |
||
139 | { |
||
140 | return new Assert\Collection([ |
||
141 | 'address_line1' => $this->buildElement('string', 1, ['max'=>50]), |
||
142 | 'address_line2' => new Assert\Optional( |
||
143 | $this->buildElement('string', 1, ['max'=>50]) |
||
144 | ), |
||
145 | 'address_line3' => new Assert\Optional( |
||
146 | $this->buildElement('string', 0, ['max'=>50]) |
||
147 | ), |
||
148 | 'city' => $this->buildElement('string', 1, ['max'=>50]), |
||
149 | 'country' => $this->buildElement('string', 1, ['max'=>10]), |
||
187 |