Passed
Push — master ( 08fae3...1a271c )
by Dmitry
01:56
created
src/Exception/Runtime.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
          *      @param string $message
21 21
          *      @param \Throwable $previous
22 22
          */
23
-        public function __construct($message, $code=0, \Exception $previous=null)
23
+        public function __construct($message, $code = 0, \Exception $previous = null)
24 24
         {
25 25
                 parent::__construct($message, $code, $previous, true);
26 26
         }
Please login to merge, or discard this patch.
src/Exception/General.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@
 block discarded – undo
21 21
          *      @param string $message
22 22
          *      @param \Throwable $previous
23 23
          */
24
-        public function __construct($message, $code=0, \Exception $previous=null, $tracelog=false)
24
+        public function __construct($message, $code = 0, \Exception $previous = null, $tracelog = false)
25 25
         {
26
-                Log::instance()->error($message.(($tracelog)?PHP_EOL.$this->getTraceAsString():null));
26
+                Log::instance()->error($message.(($tracelog) ?PHP_EOL.$this->getTraceAsString() : null));
27 27
                 parent::__construct($message, $code, $previous);
28 28
         }
29 29
 }
Please login to merge, or discard this patch.
src/Provider31/Request/General.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         /**
45 45
          *      @var array list of possible operations
46 46
          */
47
-        protected $operations = array('Check','Payment','Confirm','Cancel');
47
+        protected $operations = array('Check', 'Payment', 'Confirm', 'Cancel');
48 48
 
49 49
         /**
50 50
          *      General constructor
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 $doc = new \DOMDocument();
115 115
                 if ( ! $doc->loadXML($this->raw_request))
116 116
                 {
117
-                        foreach(libxml_get_errors() as $e){
117
+                        foreach (libxml_get_errors() as $e) {
118 118
                                 Log::instance()->error($e->message);
119 119
                         }
120 120
                         throw new Exception\Structure('The wrong XML is received', -51);
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
          */
227 227
         public function verify_sign($options)
228 228
         {
229
-                if (!isset($options['UseSign']) || ($options['UseSign'] === false))
229
+                if ( ! isset($options['UseSign']) || ($options['UseSign'] === false))
230 230
                 {
231 231
                         return null;
232 232
                 }
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
          *
281 281
          *      @return array nodes with the name
282 282
          */
283
-        protected function getNodes($dom, $name, $ret=array())
283
+        protected function getNodes($dom, $name, $ret = array())
284 284
         {
285
-                foreach($dom->childNodes as $child)
285
+                foreach ($dom->childNodes as $child)
286 286
                 {
287 287
                         if ($child->nodeName == $name)
288 288
                         {
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -133,18 +133,15 @@  discard block
 block discarded – undo
133 133
                         if ($child->nodeName == 'DateTime')
134 134
                         {
135 135
                                 $this->parse_request_node($child, 'DateTime');
136
-                        }
137
-                        elseif ($child->nodeName == 'Sign')
136
+                        } elseif ($child->nodeName == 'Sign')
138 137
                         {
139 138
                                 $this->parse_request_node($child, 'Sign');
140
-                        }
141
-                        elseif (in_array($child->nodeName, $this->operations))
139
+                        } elseif (in_array($child->nodeName, $this->operations))
142 140
                         {
143 141
                                 if ( ! isset($this->Operation))
144 142
                                 {
145 143
                                         $this->Operation = $child->nodeName;
146
-                                }
147
-                                else
144
+                                } else
148 145
                                 {
149 146
                                         throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53);
150 147
                                 }
@@ -181,8 +178,7 @@  discard block
 block discarded – undo
181 178
                 if ( ! isset($this->$name))
182 179
                 {
183 180
                         $this->$name = $n->nodeValue;
184
-                }
185
-                else
181
+                } else
186 182
                 {
187 183
                         throw new Exception\Structure('There is more than one '.$name.' element in the xml-query!', -56);
188 184
                 }
@@ -264,8 +260,7 @@  discard block
 block discarded – undo
264 260
                 if ($check == -1)
265 261
                 {
266 262
                         throw new Exception\Sign('Error verify signature of request!', -96);
267
-                }
268
-                elseif ($check == 0)
263
+                } elseif ($check == 0)
269 264
                 {
270 265
                         throw new Exception\Sign('Signature of request is incorrect!', -95);
271 266
                 }
@@ -287,8 +282,7 @@  discard block
 block discarded – undo
287 282
                         if ($child->nodeName == $name)
288 283
                         {
289 284
                                 array_push($ret, $child);
290
-                        }
291
-                        else
285
+                        } else
292 286
                         {
293 287
                                 if (count($child->childNodes) > 0)
294 288
                                 {
Please login to merge, or discard this patch.
src/Key.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -4,60 +4,60 @@
 block discarded – undo
4 4
 
5 5
 class Key
6 6
 {
7
-    public function __construct() {}
8
-
9
-    /**
10
-     *      Get content of key file
11
-     *      @param string $fname
12
-     *      @param string $type
13
-     *      @return string
14
-     *      @throws Exception\Runtime
15
-     */
16
-    public function get($fname, $type)
17
-    {
7
+        public function __construct() {}
8
+
9
+        /**
10
+         *      Get content of key file
11
+         *      @param string $fname
12
+         *      @param string $type
13
+         *      @return string
14
+         *      @throws Exception\Runtime
15
+         */
16
+        public function get($fname, $type)
17
+        {
18 18
         try
19 19
         {
20
-            $this->check_exists($fname);
20
+                $this->check_exists($fname);
21 21
 
22
-            $key = $this->load($fname);
22
+                $key = $this->load($fname);
23 23
         }
24 24
         catch (\Exception $e)
25 25
         {
26
-            throw new Exception\Runtime('The file with the '.$type.' key was '.$e->getMessage().'!', -98);
26
+                throw new Exception\Runtime('The file with the '.$type.' key was '.$e->getMessage().'!', -98);
27 27
         }
28 28
 
29 29
         return $key;
30
-    }
31
-
32
-    /**
33
-     *      Check if exist key file
34
-     *
35
-     *      @param string $fname
36
-     *      @throws Exception\Runtime
37
-     */
38
-    protected function check_exists($fname)
39
-    {
30
+        }
31
+
32
+        /**
33
+         *      Check if exist key file
34
+         *
35
+         *      @param string $fname
36
+         *      @throws Exception\Runtime
37
+         */
38
+        protected function check_exists($fname)
39
+        {
40 40
         if ( ! file_exists($fname))
41 41
         {
42
-            throw new Exception\Runtime('not exists');
42
+                throw new Exception\Runtime('not exists');
43 43
         }
44
-    }
45
-
46
-    /**
47
-     *      Load key file
48
-     *
49
-     *      @param string $fname
50
-     *      @return string
51
-     *      @throws Exception\Runtime
52
-     */
53
-    protected function load($fname)
54
-    {
44
+        }
45
+
46
+        /**
47
+         *      Load key file
48
+         *
49
+         *      @param string $fname
50
+         *      @return string
51
+         *      @throws Exception\Runtime
52
+         */
53
+        protected function load($fname)
54
+        {
55 55
         $key = @file_get_contents($fname);
56 56
         if ($key === FALSE)
57 57
         {
58
-            throw new Exception\Runtime('not read');
58
+                throw new Exception\Runtime('not read');
59 59
         }
60 60
 
61 61
         return $key;
62
-    }
62
+        }
63 63
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@
 block discarded – undo
20 20
             $this->check_exists($fname);
21 21
 
22 22
             $key = $this->load($fname);
23
-        }
24
-        catch (\Exception $e)
23
+        } catch (\Exception $e)
25 24
         {
26 25
             throw new Exception\Runtime('The file with the '.$type.' key was '.$e->getMessage().'!', -98);
27 26
         }
Please login to merge, or discard this patch.
src/Provider31/Response/ErrorInfo.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@
 block discarded – undo
15 15
 
16 16
 final class ErrorInfo extends Response
17 17
 {
18
-	/**
19
-     *      ErrorInfo constructor
20
-     *
21
-     *      @param integer $code Error code
22
-     *      @param string $message Error message text
23
-     */
24
-    public function __construct($code, $message)
25
-    {
26
-		parent::__construct();
18
+        /**
19
+         *      ErrorInfo constructor
20
+         *
21
+         *      @param integer $code Error code
22
+         *      @param string $message Error message text
23
+         */
24
+        public function __construct($code, $message)
25
+        {
26
+                parent::__construct();
27 27
 
28
-		$this->setElementValue('StatusCode', $code);
29
-		$this->setElementValue('StatusDetail', $message);
30
-	}
28
+                $this->setElementValue('StatusCode', $code);
29
+                $this->setElementValue('StatusDetail', $message);
30
+        }
31 31
 }
Please login to merge, or discard this patch.
src/Provider31/Request.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,52 +15,52 @@  discard block
 block discarded – undo
15 15
 
16 16
 final class Request
17 17
 {
18
-    /**
19
-     *      static method to create a specific class of request
20
-     *
21
-     *      @return Request\General Request class of the appropriate type
22
-     *      @throws Exception\Structure
23
-     */
24
-    public static function get()
25
-    {
18
+        /**
19
+         *      static method to create a specific class of request
20
+         *
21
+         *      @return Request\General Request class of the appropriate type
22
+         *      @throws Exception\Structure
23
+         */
24
+        public static function get()
25
+        {
26 26
         $raw = self::get_http_raw_post_data();
27 27
 
28 28
         $r = new Request\General($raw);
29 29
 
30 30
         switch ($r->Operation())
31 31
         {
32
-            case 'Check':
32
+                case 'Check':
33 33
                 return new Request\Check($raw);
34 34
 
35
-            case 'Payment':
35
+                case 'Payment':
36 36
                 return new Request\Payment($raw);
37 37
 
38
-            case 'Confirm':
38
+                case 'Confirm':
39 39
                 return new Request\Confirm($raw);
40 40
 
41
-            case 'Cancel';
41
+                case 'Cancel';
42 42
                 return new Request\Cancel($raw);
43 43
 
44
-            default:
44
+                default:
45 45
                 throw new Exception\Structure('There is not supported value of Operation in xml-request!', -99);
46 46
         }
47
-    }
47
+        }
48 48
 
49
-    /**
50
-     *      Get data from the body of the http request
51
-     *
52
-     *      - with the appropriate configuration of php.ini they can be found
53
-     *        in the global variable $HTTP_RAW_POST_DATA
54
-     *
55
-     *      - but it's easier just to read the data from the php://input stream,
56
-     *        which does not depend on the php.ini directives and allows you to read
57
-     *        raw data from the request body
58
-     *
59
-     *      @return string Http raw post data
60
-     *
61
-     */
62
-    private static function get_http_raw_post_data()
63
-    {
49
+        /**
50
+         *      Get data from the body of the http request
51
+         *
52
+         *      - with the appropriate configuration of php.ini they can be found
53
+         *        in the global variable $HTTP_RAW_POST_DATA
54
+         *
55
+         *      - but it's easier just to read the data from the php://input stream,
56
+         *        which does not depend on the php.ini directives and allows you to read
57
+         *        raw data from the request body
58
+         *
59
+         *      @return string Http raw post data
60
+         *
61
+         */
62
+        private static function get_http_raw_post_data()
63
+        {
64 64
         Log::instance()->add('request from ' . $_SERVER['REMOTE_ADDR']);
65 65
 
66 66
         $raw_request = file_get_contents('php://input');
@@ -70,5 +70,5 @@  discard block
 block discarded – undo
70 70
         Log::instance()->debug(' ');
71 71
 
72 72
         return $raw_request;
73
-    }
73
+        }
74 74
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
      */
62 62
     private static function get_http_raw_post_data()
63 63
     {
64
-        Log::instance()->add('request from ' . $_SERVER['REMOTE_ADDR']);
64
+        Log::instance()->add('request from '.$_SERVER['REMOTE_ADDR']);
65 65
 
66 66
         $raw_request = file_get_contents('php://input');
67 67
 
Please login to merge, or discard this patch.
src/Provider31/Response.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
      *      @param string $name
53 53
      *      @param string $value (optional)
54 54
      */
55
-    public function createElement($name, $value=NULL)
55
+    public function createElement($name, $value = NULL)
56 56
     {
57 57
         return parent::createElement($name, $value);
58 58
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -124,7 +124,9 @@  discard block
 block discarded – undo
124 124
      */
125 125
     protected function sign($options)
126 126
     {
127
-        if (isset($this->Sign)) return;
127
+        if (isset($this->Sign)) {
128
+                return;
129
+        }
128 130
 
129 131
         if (isset($options['UseSign']) && ($options['UseSign'] === true))
130 132
         {
@@ -153,8 +155,7 @@  discard block
 block discarded – undo
153 155
         try
154 156
         {
155 157
             $pkeyid = (new Key())->get($options['ProviderPKey'], 'private');
156
-        }
157
-        catch (\Exception $e)
158
+        } catch (\Exception $e)
158 159
         {
159 160
             return null;
160 161
         }
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -16,93 +16,93 @@  discard block
 block discarded – undo
16 16
 
17 17
 abstract class Response extends \DomDocument
18 18
 {
19
-    /**
20
-     *      @var string
21
-     *
22
-     */
23
-    const TEMPLATE = '<Response><StatusCode></StatusCode><StatusDetail></StatusDetail><DateTime></DateTime></Response>';
24
-
25
-    /**
26
-     *      @var \DOMNode
27
-     */
28
-    protected $Response;
29
-
30
-    /**
31
-     *      @var \DOMElement
32
-     */
33
-    protected $Sign;
34
-
35
-    /**
36
-     *      Response constructor
37
-     *
38
-     */
39
-    public function __construct()
40
-    {
19
+        /**
20
+         *      @var string
21
+         *
22
+         */
23
+        const TEMPLATE = '<Response><StatusCode></StatusCode><StatusDetail></StatusDetail><DateTime></DateTime></Response>';
24
+
25
+        /**
26
+         *      @var \DOMNode
27
+         */
28
+        protected $Response;
29
+
30
+        /**
31
+         *      @var \DOMElement
32
+         */
33
+        protected $Sign;
34
+
35
+        /**
36
+         *      Response constructor
37
+         *
38
+         */
39
+        public function __construct()
40
+        {
41 41
         parent::__construct('1.0', 'UTF-8');
42 42
 
43 43
         $this->loadXML(self::TEMPLATE);
44 44
 
45 45
         $this->Response = $this->firstChild;
46 46
         $this->set_DateTime();
47
-    }
47
+        }
48 48
 
49
-    /**
50
-     *      Set DateTime element value by current time
51
-     */
52
-    public function set_DateTime()
53
-    {
49
+        /**
50
+         *      Set DateTime element value by current time
51
+         */
52
+        public function set_DateTime()
53
+        {
54 54
         $this->setElementValue('DateTime', date('Y-m-d\TH:i:s', time()));
55
-    }
56
-
57
-    /**
58
-     *      Create new element node
59
-     *
60
-     *      @param string $name
61
-     *      @param string $value (optional)
62
-     */
63
-    public function createElement($name, $value=NULL)
64
-    {
55
+        }
56
+
57
+        /**
58
+         *      Create new element node
59
+         *
60
+         *      @param string $name
61
+         *      @param string $value (optional)
62
+         */
63
+        public function createElement($name, $value=NULL)
64
+        {
65 65
         return parent::createElement($name, $value);
66
-    }
67
-
68
-    /**
69
-     *      Set node value
70
-     *
71
-     *      @param string $name
72
-     *      @param string $value
73
-     */
74
-    public function setElementValue($name, $value)
75
-    {
66
+        }
67
+
68
+        /**
69
+         *      Set node value
70
+         *
71
+         *      @param string $name
72
+         *      @param string $value
73
+         */
74
+        public function setElementValue($name, $value)
75
+        {
76 76
         foreach ($this->Response->childNodes as $child)
77 77
         {
78
-            if ($child->nodeName == $name)
79
-            {
78
+                if ($child->nodeName == $name)
79
+                {
80 80
                 $child->nodeValue = $value;
81
-            }
81
+                }
82 82
         }
83
-    }
84
-
85
-    /**
86
-     *      Dumps response into a string
87
-     *
88
-     *      @return string XML
89
-     */
90
-    public function friendly()
91
-    {
83
+        }
84
+
85
+        /**
86
+         *      Dumps response into a string
87
+         *
88
+         *      @return string XML
89
+         */
90
+        public function friendly()
91
+        {
92 92
         $this->encoding = 'UTF-8';
93 93
         $this->formatOutput = true;
94 94
         //$this->save('/tmp/test1.xml');
95 95
 
96 96
         return $this->saveXML(NULL, LIBXML_NOEMPTYTAG);
97
-    }
98
-
99
-    /**
100
-     *      Send response
101
-     *
102
-     *      @param array $options
103
-     */
104
-    public function out($options)
105
-    {
97
+        }
98
+
99
+        /**
100
+         *      Send response
101
+         *
102
+         *      @param array $options
103
+         */
104
+        public function out($options)
105
+        {
106 106
         $this->sign($options);
107 107
 
108 108
         Log::instance()->debug('response sends: ');
@@ -112,62 +112,62 @@  discard block
 block discarded – undo
112 112
         header("Content-Type: text/xml; charset=utf-8");
113 113
         echo $this->friendly();
114 114
         exit;
115
-    }
116
-
117
-    /**
118
-     *      Add Sign (if hasn't yet done)
119
-     *
120
-     *      @param array $options
121
-     */
122
-    protected function sign($options)
123
-    {
115
+        }
116
+
117
+        /**
118
+         *      Add Sign (if hasn't yet done)
119
+         *
120
+         *      @param array $options
121
+         */
122
+        protected function sign($options)
123
+        {
124 124
         if (isset($this->Sign)) return;
125 125
 
126 126
         if (isset($options['UseSign']) && ($options['UseSign'] === true))
127 127
         {
128
-            $this->Sign = $this->createElement('Sign');
129
-            $this->Response->appendChild($this->Sign);
128
+                $this->Sign = $this->createElement('Sign');
129
+                $this->Response->appendChild($this->Sign);
130 130
 
131
-            $sign = $this->generate_sign($options);
131
+                $sign = $this->generate_sign($options);
132 132
 
133
-            $this->Sign->nodeValue = $sign;
133
+                $this->Sign->nodeValue = $sign;
134
+        }
134 135
         }
135
-    }
136
-
137
-    /**
138
-     *      Generate signature of response
139
-     *
140
-     *      @param array $options
141
-     *      @return string
142
-     */
143
-    public function generate_sign($options)
144
-    {
136
+
137
+        /**
138
+         *      Generate signature of response
139
+         *
140
+         *      @param array $options
141
+         *      @return string
142
+         */
143
+        public function generate_sign($options)
144
+        {
145 145
         if ( ! isset($options['ProviderPKey']))
146 146
         {
147
-            Log::instance()->error('The parameter ProviderPKey is not set!');
148
-            return null;
147
+                Log::instance()->error('The parameter ProviderPKey is not set!');
148
+                return null;
149 149
         }
150 150
         try
151 151
         {
152
-            $pkeyid = (new Key())->get($options['ProviderPKey'], 'private');
152
+                $pkeyid = (new Key())->get($options['ProviderPKey'], 'private');
153 153
         }
154 154
         catch (\Exception $e)
155 155
         {
156
-            return null;
156
+                return null;
157 157
         }
158 158
 
159 159
         $pr_key = openssl_pkey_get_private($pkeyid);
160 160
         if ($pr_key === FALSE)
161 161
         {
162
-            Log::instance()->error('Can not extract the private key from certificate!');
163
-            return null;
162
+                Log::instance()->error('Can not extract the private key from certificate!');
163
+                return null;
164 164
         }
165 165
         if (openssl_sign($this->friendly(), $sign, $pr_key) === FALSE)
166 166
         {
167
-            Log::instance()->error('Can not generate signature!');
168
-            return null;
167
+                Log::instance()->error('Can not generate signature!');
168
+                return null;
169 169
         }
170 170
 
171 171
         return strtoupper(bin2hex($sign));
172
-    }
172
+        }
173 173
 }
Please login to merge, or discard this patch.
src/Provider31.php 2 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -71,20 +71,16 @@
 block discarded – undo
71 71
             $this->response = $this->get_response();
72 72
 
73 73
             Log::instance()->add('the request was processed successfully');
74
-        }
75
-        catch (Exception\Structure $e)
74
+        } catch (Exception\Structure $e)
76 75
         {
77 76
             $this->response = $this->get_error_response($e->getCode(), 'Error in request');
78
-        }
79
-        catch (Exception\Sign $e)
77
+        } catch (Exception\Sign $e)
80 78
         {
81 79
             $this->response = $this->get_error_response($e->getCode(), 'Signature error!');
82
-        }
83
-        catch (Exception\Runtime $e)
80
+        } catch (Exception\Runtime $e)
84 81
         {
85 82
             $this->response = $this->get_error_response($e->getCode(), 'Error while processing request');
86
-        }
87
-        catch (\Exception $e)
83
+        } catch (\Exception $e)
88 84
         {
89 85
             $this->response = $this->get_error_response($e->getCode(), $e->getMessage());
90 86
         }
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 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 Callback
28
-     */
29
-    protected static $cb;
30
-
31
-    /**
32
-     *      @var Request\General
33
-     */
34
-    private $request;
35
-
36
-    /**
37
-     *      Provider31 constructor
38
-     *
39
-     *      @param array $options
40
-     *      @param Callback $cb
41
-     *      @param \Debulog\LoggerInterface $log
42
-     */
43
-    public function __construct(array $options, Callback $cb, \Debulog\LoggerInterface $log)
44
-    {
24
+        );
25
+
26
+        /**
27
+         *      @var Callback
28
+         */
29
+        protected static $cb;
30
+
31
+        /**
32
+         *      @var Request\General
33
+         */
34
+        private $request;
35
+
36
+        /**
37
+         *      Provider31 constructor
38
+         *
39
+         *      @param array $options
40
+         *      @param Callback $cb
41
+         *      @param \Debulog\LoggerInterface $log
42
+         */
43
+        public function __construct(array $options, Callback $cb, \Debulog\LoggerInterface $log)
44
+        {
45 45
         self::$options = array_merge(self::$options, $options);
46 46
         self::$cb = $cb;
47 47
 
48 48
         Log::set($log);
49
-    }
50
-
51
-    /**
52
-     *      Get and process request, echo response
53
-     *
54
-     */
55
-    public function process()
56
-    {
49
+        }
50
+
51
+        /**
52
+         *      Get and process request, echo response
53
+         *
54
+         */
55
+        public function process()
56
+        {
57 57
         try
58 58
         {
59
-            //      get request
60
-            $this->request = Provider31\Request::get();
59
+                //      get request
60
+                $this->request = Provider31\Request::get();
61 61
 
62
-            //      validate request
63
-            $this->request->validate_request(self::$options);
64
-            Log::instance()->debug('request is valid');
62
+                //      validate request
63
+                $this->request->validate_request(self::$options);
64
+                Log::instance()->debug('request is valid');
65 65
 
66
-            //      verify sign
67
-            $this->request->verify_sign(self::$options);
68
-            Log::instance()->debug('signature of request is correct');
66
+                //      verify sign
67
+                $this->request->verify_sign(self::$options);
68
+                Log::instance()->debug('signature of request is correct');
69 69
 
70
-            //      get response
71
-            $this->response = $this->get_response();
70
+                //      get response
71
+                $this->response = $this->get_response();
72 72
 
73
-            Log::instance()->add('the request was processed successfully');
73
+                Log::instance()->add('the request was processed successfully');
74 74
         }
75 75
         catch (Exception\Structure $e)
76 76
         {
77
-            $this->response = $this->get_error_response($e->getCode(), 'Error in request');
77
+                $this->response = $this->get_error_response($e->getCode(), 'Error in request');
78 78
         }
79 79
         catch (Exception\Sign $e)
80 80
         {
81
-            $this->response = $this->get_error_response($e->getCode(), 'Signature error!');
81
+                $this->response = $this->get_error_response($e->getCode(), 'Signature error!');
82 82
         }
83 83
         catch (Exception\Runtime $e)
84 84
         {
85
-            $this->response = $this->get_error_response($e->getCode(), 'Error while processing request');
85
+                $this->response = $this->get_error_response($e->getCode(), 'Error while processing request');
86 86
         }
87 87
         catch (\Exception $e)
88 88
         {
89
-            $this->response = $this->get_error_response($e->getCode(), $e->getMessage());
89
+                $this->response = $this->get_error_response($e->getCode(), $e->getMessage());
90 90
         }
91 91
 
92 92
         //      output response
93 93
         $this->response->out(self::$options);
94
-    }
95
-
96
-    /**
97
-     *      Process request and generate response
98
-     *
99
-     *      @throws Exception\Structure
100
-     */
101
-    private function get_response()
102
-    {
94
+        }
95
+
96
+        /**
97
+         *      Process request and generate response
98
+         *
99
+         *      @throws Exception\Structure
100
+         */
101
+        private function get_response()
102
+        {
103 103
         switch ($this->request->Operation())
104 104
         {
105
-            case 'Check':
105
+                case 'Check':
106 106
 
107 107
                 return $this->response_check();
108 108
 
109
-            case 'Payment':
109
+                case 'Payment':
110 110
 
111 111
                 return $this->response_payment();
112 112
 
113
-            case 'Confirm':
113
+                case 'Confirm':
114 114
 
115 115
                 return $this->response_confirm();
116 116
 
117
-            case 'Cancel';
117
+                case 'Cancel';
118 118
 
119 119
                 return $this->response_cancel();
120 120
 
121
-            default:
121
+                default:
122 122
                 break;
123 123
         }
124 124
 
125 125
         throw new Exception\Structure('There is not supported value of Operation in xml-request!', -99);
126
-    }
127
-
128
-    /**
129
-     *      run check callback and generate a response
130
-     *
131
-     *      @return Provider31\Response\Check
132
-     */
133
-    private function response_check()
134
-    {
126
+        }
127
+
128
+        /**
129
+         *      run check callback and generate a response
130
+         *
131
+         *      @return Provider31\Response\Check
132
+         */
133
+        private function response_check()
134
+        {
135 135
         Log::instance()->add(sprintf('Check("%s")', $this->request->Account()));
136 136
 
137 137
         $accountinfo = self::$cb->check(
138
-            $this->request->Account()
138
+                $this->request->Account()
139 139
         );
140 140
 
141 141
         // Sending a response
142 142
         return new Provider31\Response\Check($accountinfo);
143
-    }
144
-
145
-    /**
146
-     *      run payment callback and generate a response
147
-     *
148
-     *      @return Provider31\Response\Payment
149
-     */
150
-    private function response_payment()
151
-    {
143
+        }
144
+
145
+        /**
146
+         *      run payment callback and generate a response
147
+         *
148
+         *      @return Provider31\Response\Payment
149
+         */
150
+        private function response_payment()
151
+        {
152 152
         Log::instance()->add(sprintf('Payment("%s", "%s", "%s")', $this->request->Account(), $this->request->OrderId(), $this->request->Amount()));
153 153
 
154 154
         $paymentid = self::$cb->payment(
155
-            $this->request->Account(),
156
-            $this->request->OrderId(),
157
-            $this->request->Amount()
155
+                $this->request->Account(),
156
+                $this->request->OrderId(),
157
+                $this->request->Amount()
158 158
         );
159 159
 
160 160
         // Sending a response
161 161
         return new Provider31\Response\Payment($paymentid);
162
-    }
163
-
164
-    /**
165
-     *      run confirm callback and generate a response
166
-     *
167
-     *      @return Provider31\Response\Confirm
168
-     */
169
-    private function response_confirm()
170
-    {
162
+        }
163
+
164
+        /**
165
+         *      run confirm callback and generate a response
166
+         *
167
+         *      @return Provider31\Response\Confirm
168
+         */
169
+        private function response_confirm()
170
+        {
171 171
         Log::instance()->add(sprintf('Confirm("%s")', $this->request->PaymentId()));
172 172
 
173 173
         $orderdate = self::$cb->confirm(
174
-            $this->request->PaymentId()
174
+                $this->request->PaymentId()
175 175
         );
176 176
 
177 177
         // Sending a response
178 178
         return new Provider31\Response\Confirm($orderdate);
179
-    }
180
-
181
-    /**
182
-     *      run cancel callback and generate a response
183
-     *
184
-     *      @return Provider31\Response\Cancel
185
-     */
186
-    private function response_cancel()
187
-    {
179
+        }
180
+
181
+        /**
182
+         *      run cancel callback and generate a response
183
+         *
184
+         *      @return Provider31\Response\Cancel
185
+         */
186
+        private function response_cancel()
187
+        {
188 188
         Log::instance()->add(sprintf('Cancel("%s")', $this->request->PaymentId()));
189 189
 
190 190
         $canceldate = self::$cb->cancel(
191
-            $this->request->PaymentId()
191
+                $this->request->PaymentId()
192 192
         );
193 193
 
194 194
         // Sending a response
195 195
         return new Provider31\Response\Cancel($canceldate);
196
-    }
197
-
198
-    /**
199
-     *      Generates an xml with an error message
200
-     *
201
-     *      @param integer $code
202
-     *      @param string $message
203
-     *
204
-     *      @return Provider31\Response\ErrorInfo
205
-     */
206
-    private function get_error_response($code, $message)
207
-    {
196
+        }
197
+
198
+        /**
199
+         *      Generates an xml with an error message
200
+         *
201
+         *      @param integer $code
202
+         *      @param string $message
203
+         *
204
+         *      @return Provider31\Response\ErrorInfo
205
+         */
206
+        private function get_error_response($code, $message)
207
+        {
208 208
         Log::instance()->add('the request was processed with an error');
209 209
 
210 210
         // Sending a response
211 211
         return new Provider31\Response\ErrorInfo($code, $message);
212
-    }
212
+        }
213 213
 }
Please login to merge, or discard this patch.
src/Provider31/Response/Check.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -16,41 +16,41 @@
 block discarded – undo
16 16
 
17 17
 final class Check extends Response
18 18
 {
19
-    /**
20
-     *      @var \DOMElement
21
-     */
22
-    protected $AccountInfo;
23
-
24
-	/**
25
-     *      Check constructor
26
-     *
27
-     *      @param AccountInfo $accountinfo account information set
28
-     */
29
-    public function __construct(AccountInfo $accountinfo)
30
-    {
31
-		parent::__construct();
32
-
33
-		$this->setElementValue('StatusCode', 0);
34
-		$this->setElementValue('StatusDetail', 'checked');
35
-
36
-		$this->create_AccountInfo($accountinfo);
37
-	}
38
-
39
-	/**
40
-     *      Create AccountInfo node with child nodes
41
-     *
42
-     *      @param AccountInfo $accountinfo account information set
43
-     */
44
-	public function create_AccountInfo($accountinfo)
45
-	{
46
-		if (isset($this->AccountInfo)) return;
47
-
48
-		$this->AccountInfo = $this->createElement('AccountInfo');
49
-		$this->Response->appendChild($this->AccountInfo);
50
-
51
-		foreach($accountinfo as $parameter=>$value)
52
-		{
53
-			$this->AccountInfo->appendChild($this->createElement($parameter, $value));
54
-		}
55
-	}
19
+        /**
20
+         *      @var \DOMElement
21
+         */
22
+        protected $AccountInfo;
23
+
24
+        /**
25
+         *      Check constructor
26
+         *
27
+         *      @param AccountInfo $accountinfo account information set
28
+         */
29
+        public function __construct(AccountInfo $accountinfo)
30
+        {
31
+                parent::__construct();
32
+
33
+                $this->setElementValue('StatusCode', 0);
34
+                $this->setElementValue('StatusDetail', 'checked');
35
+
36
+                $this->create_AccountInfo($accountinfo);
37
+        }
38
+
39
+        /**
40
+         *      Create AccountInfo node with child nodes
41
+         *
42
+         *      @param AccountInfo $accountinfo account information set
43
+         */
44
+        public function create_AccountInfo($accountinfo)
45
+        {
46
+                if (isset($this->AccountInfo)) return;
47
+
48
+                $this->AccountInfo = $this->createElement('AccountInfo');
49
+                $this->Response->appendChild($this->AccountInfo);
50
+
51
+                foreach($accountinfo as $parameter=>$value)
52
+                {
53
+                        $this->AccountInfo->appendChild($this->createElement($parameter, $value));
54
+                }
55
+        }
56 56
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 		$this->AccountInfo = $this->createElement('AccountInfo');
49 49
 		$this->Response->appendChild($this->AccountInfo);
50 50
 
51
-		foreach($accountinfo as $parameter=>$value)
51
+		foreach ($accountinfo as $parameter=>$value)
52 52
 		{
53 53
 			$this->AccountInfo->appendChild($this->createElement($parameter, $value));
54 54
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@
 block discarded – undo
43 43
      */
44 44
 	public function create_AccountInfo($accountinfo)
45 45
 	{
46
-		if (isset($this->AccountInfo)) return;
46
+		if (isset($this->AccountInfo)) {
47
+		        return;
48
+		}
47 49
 
48 50
 		$this->AccountInfo = $this->createElement('AccountInfo');
49 51
 		$this->Response->appendChild($this->AccountInfo);
Please login to merge, or discard this patch.