Passed
Push — master ( 80c89b...178b52 )
by Dmitry
02:12
created
src/Provider31.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -13,201 +13,201 @@
 block discarded – undo
13 13
 
14 14
 class Provider31
15 15
 {
16
-    /**
17
-     *      @var array
18
-     */
19
-    protected static $options = array(
16
+        /**
17
+         *      @var array
18
+         */
19
+        protected static $options = array(
20 20
         'ServiceId' => 0,
21 21
         'UseSign' => false,
22 22
         'EasySoftPKey' => '',
23 23
         'ProviderPKey' => '',
24
-    );
25
-
26
-    /**
27
-     *      @var \EasyPay\Callback
28
-     */
29
-    protected static $cb;
30
-
31
-    /**
32
-     *      @var mixed
33
-     */
34
-    protected $request;
35
-
36
-    /**
37
-     *      @var Provider31\Response
38
-     */
39
-    protected $response;
40
-
41
-    /**
42
-     *      Provider31 constructor
43
-     *
44
-     *      @param array $options
45
-     *      @param Callback $cb
46
-     *      @param \Debulog\LoggerInterface $log
47
-     */
48
-    public function __construct(array $options, \EasyPay\Callback $cb, \Debulog\LoggerInterface $log)
49
-    {
24
+        );
25
+
26
+        /**
27
+         *      @var \EasyPay\Callback
28
+         */
29
+        protected static $cb;
30
+
31
+        /**
32
+         *      @var mixed
33
+         */
34
+        protected $request;
35
+
36
+        /**
37
+         *      @var Provider31\Response
38
+         */
39
+        protected $response;
40
+
41
+        /**
42
+         *      Provider31 constructor
43
+         *
44
+         *      @param array $options
45
+         *      @param Callback $cb
46
+         *      @param \Debulog\LoggerInterface $log
47
+         */
48
+        public function __construct(array $options, \EasyPay\Callback $cb, \Debulog\LoggerInterface $log)
49
+        {
50 50
         self::$options = array_merge(self::$options, $options);
51 51
         self::$cb = $cb;
52 52
 
53 53
         Log::set($log);
54
-    }
55
-
56
-    /**
57
-     *      Get and process request, echo response
58
-     *
59
-     */
60
-    public function process()
61
-    {
54
+        }
55
+
56
+        /**
57
+         *      Get and process request, echo response
58
+         *
59
+         */
60
+        public function process()
61
+        {
62 62
         try
63 63
         {
64
-            //      get request
65
-            $this->get_request();
64
+                //      get request
65
+                $this->get_request();
66 66
 
67
-            //      validate request
68
-            $this->request->validate_request(self::$options);
69
-            Log::instance()->debug('request is valid');
67
+                //      validate request
68
+                $this->request->validate_request(self::$options);
69
+                Log::instance()->debug('request is valid');
70 70
 
71
-            //      verify sign
72
-            $this->request->verify_sign(self::$options);
73
-            Log::instance()->debug('signature of request is correct');
71
+                //      verify sign
72
+                $this->request->verify_sign(self::$options);
73
+                Log::instance()->debug('signature of request is correct');
74 74
 
75
-            //      get response
76
-            $this->response = $this->get_response();
75
+                //      get response
76
+                $this->response = $this->get_response();
77 77
 
78
-            Log::instance()->add('the request was processed successfully');
78
+                Log::instance()->add('the request was processed successfully');
79 79
         }
80 80
         catch (\Exception $e)
81 81
         {
82
-            $this->response = $this->get_error_response($e);
82
+                $this->response = $this->get_error_response($e);
83 83
 
84
-            Log::instance()->add('the request was processed with an error');
84
+                Log::instance()->add('the request was processed with an error');
85 85
         }
86 86
 
87 87
         //      output response
88 88
         $this->response->sign_and_out(self::$options);
89
-    }
90
-
91
-    /**
92
-     *      method to create a specific class of request
93
-     *
94
-     */
95
-    protected function get_request()
96
-    {
89
+        }
90
+
91
+        /**
92
+         *      method to create a specific class of request
93
+         *
94
+         */
95
+        protected function get_request()
96
+        {
97 97
         $raw = new Provider31\Request\RAW();
98 98
 
99 99
         $r = new Provider31\Request\General($raw);
100 100
         $c = '\\EasyPay\\Provider31\\Request\\'.$r->Operation();
101 101
 
102 102
         $this->request = new $c($raw);
103
-    }
104
-
105
-    /**
106
-     *      generate response
107
-     *
108
-     *      @return mixed
109
-     */
110
-    protected function get_response()
111
-    {
103
+        }
104
+
105
+        /**
106
+         *      generate response
107
+         *
108
+         *      @return mixed
109
+         */
110
+        protected function get_response()
111
+        {
112 112
         $m = 'response_'.$this->request->Operation();
113 113
         return $this->$m();
114
-    }
115
-
116
-    /**
117
-     *      run check callback and generate a response
118
-     *
119
-     *      @return Provider31\Response\Check
120
-     */
121
-    private function response_Check()
122
-    {
114
+        }
115
+
116
+        /**
117
+         *      run check callback and generate a response
118
+         *
119
+         *      @return Provider31\Response\Check
120
+         */
121
+        private function response_Check()
122
+        {
123 123
         Log::instance()->add(sprintf('Check("%s")', $this->request->Account()));
124 124
 
125 125
         $accountinfo = self::$cb->check(
126
-            $this->request->Account()
126
+                $this->request->Account()
127 127
         );
128 128
 
129 129
         // Sending a response
130 130
         return new Provider31\Response\Check($accountinfo);
131
-    }
132
-
133
-    /**
134
-     *      run payment callback and generate a response
135
-     *
136
-     *      @return Provider31\Response\Payment
137
-     */
138
-    private function response_Payment()
139
-    {
131
+        }
132
+
133
+        /**
134
+         *      run payment callback and generate a response
135
+         *
136
+         *      @return Provider31\Response\Payment
137
+         */
138
+        private function response_Payment()
139
+        {
140 140
         Log::instance()->add(sprintf('Payment("%s", "%s", "%s")', $this->request->Account(), $this->request->OrderId(), $this->request->Amount()));
141 141
 
142 142
         $paymentid = self::$cb->payment(
143
-            $this->request->Account(),
144
-            $this->request->OrderId(),
145
-            $this->request->Amount()
143
+                $this->request->Account(),
144
+                $this->request->OrderId(),
145
+                $this->request->Amount()
146 146
         );
147 147
 
148 148
         // Sending a response
149 149
         return new Provider31\Response\Payment($paymentid);
150
-    }
151
-
152
-    /**
153
-     *      run confirm callback and generate a response
154
-     *
155
-     *      @return Provider31\Response\Confirm
156
-     */
157
-    private function response_Confirm()
158
-    {
150
+        }
151
+
152
+        /**
153
+         *      run confirm callback and generate a response
154
+         *
155
+         *      @return Provider31\Response\Confirm
156
+         */
157
+        private function response_Confirm()
158
+        {
159 159
         Log::instance()->add(sprintf('Confirm("%s")', $this->request->PaymentId()));
160 160
 
161 161
         $orderdate = self::$cb->confirm(
162
-            $this->request->PaymentId()
162
+                $this->request->PaymentId()
163 163
         );
164 164
 
165 165
         // Sending a response
166 166
         return new Provider31\Response\Confirm($orderdate);
167
-    }
168
-
169
-    /**
170
-     *      run cancel callback and generate a response
171
-     *
172
-     *      @return Provider31\Response\Cancel
173
-     */
174
-    private function response_Cancel()
175
-    {
167
+        }
168
+
169
+        /**
170
+         *      run cancel callback and generate a response
171
+         *
172
+         *      @return Provider31\Response\Cancel
173
+         */
174
+        private function response_Cancel()
175
+        {
176 176
         Log::instance()->add(sprintf('Cancel("%s")', $this->request->PaymentId()));
177 177
 
178 178
         $canceldate = self::$cb->cancel(
179
-            $this->request->PaymentId()
179
+                $this->request->PaymentId()
180 180
         );
181 181
 
182 182
         // Sending a response
183 183
         return new Provider31\Response\Cancel($canceldate);
184
-    }
185
-
186
-    /**
187
-     *      Generates an xml with an error message
188
-     *
189
-     *      @param mixed $e
190
-     *
191
-     *      @return Provider31\Response\ErrorInfo
192
-     */
193
-    private function get_error_response($e)
194
-    {
184
+        }
185
+
186
+        /**
187
+         *      Generates an xml with an error message
188
+         *
189
+         *      @param mixed $e
190
+         *
191
+         *      @return Provider31\Response\ErrorInfo
192
+         */
193
+        private function get_error_response($e)
194
+        {
195 195
         $message = $e->getMessage();
196 196
 
197 197
         if ($e instanceof Exception\Structure)
198 198
         {
199
-            $message = 'Error in request';
199
+                $message = 'Error in request';
200 200
         }
201 201
         elseif ($e instanceof Exception\Sign)
202 202
         {
203
-            $message = 'Signature error!';
203
+                $message = 'Signature error!';
204 204
         }
205 205
         elseif ($e instanceof Exception\Runtime)
206 206
         {
207
-            $message = 'Error while processing request';
207
+                $message = 'Error while processing request';
208 208
         }
209 209
 
210 210
         // Sending a response
211 211
         return new Provider31\Response\ErrorInfo($e->getCode(), $message);
212
-    }
212
+        }
213 213
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@  discard block
 block discarded – undo
76 76
             $this->response = $this->get_response();
77 77
 
78 78
             Log::instance()->add('the request was processed successfully');
79
-        }
80
-        catch (\Exception $e)
79
+        } catch (\Exception $e)
81 80
         {
82 81
             $this->response = $this->get_error_response($e);
83 82
 
@@ -197,12 +196,10 @@  discard block
 block discarded – undo
197 196
         if ($e instanceof Exception\Structure)
198 197
         {
199 198
             $message = 'Error in request';
200
-        }
201
-        elseif ($e instanceof Exception\Sign)
199
+        } elseif ($e instanceof Exception\Sign)
202 200
         {
203 201
             $message = 'Signature error!';
204
-        }
205
-        elseif ($e instanceof Exception\Runtime)
202
+        } elseif ($e instanceof Exception\Runtime)
206 203
         {
207 204
             $message = 'Error while processing request';
208 205
         }
Please login to merge, or discard this patch.