@@ -42,7 +42,7 @@ |
||
42 | 42 | $this->AccountInfo = self::createElement('AccountInfo'); |
43 | 43 | $this->Response->appendChild($this->AccountInfo); |
44 | 44 | |
45 | - foreach($accountinfo as $parameter=>$value) |
|
45 | + foreach ($accountinfo as $parameter=>$value) |
|
46 | 46 | { |
47 | 47 | $this->AccountInfo->appendChild(self::createElement($parameter, $value)); |
48 | 48 | } |
@@ -43,7 +43,9 @@ |
||
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 = self::createElement('AccountInfo'); |
49 | 51 | $this->Response->appendChild($this->AccountInfo); |
@@ -16,41 +16,41 @@ |
||
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 = self::createElement('AccountInfo'); |
|
49 | - $this->Response->appendChild($this->AccountInfo); |
|
50 | - |
|
51 | - foreach($accountinfo as $parameter=>$value) |
|
52 | - { |
|
53 | - $this->AccountInfo->appendChild(self::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 = self::createElement('AccountInfo'); |
|
49 | + $this->Response->appendChild($this->AccountInfo); |
|
50 | + |
|
51 | + foreach($accountinfo as $parameter=>$value) |
|
52 | + { |
|
53 | + $this->AccountInfo->appendChild(self::createElement($parameter, $value)); |
|
54 | + } |
|
55 | + } |
|
56 | 56 | } |
@@ -20,7 +20,7 @@ |
||
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 | } |
@@ -21,9 +21,9 @@ |
||
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 | } |
@@ -44,7 +44,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -133,18 +133,15 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -4,60 +4,60 @@ |
||
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 | } |
@@ -20,8 +20,7 @@ |
||
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 | } |
@@ -42,7 +42,9 @@ |
||
42 | 42 | */ |
43 | 43 | public function create_PaymentId($paymentid) |
44 | 44 | { |
45 | - if (isset($this->PaymentId)) return; |
|
45 | + if (isset($this->PaymentId)) { |
|
46 | + return; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | $this->PaymentId = self::createElement('PaymentId', $paymentid); |
48 | 50 | $this->Response->appendChild($this->PaymentId); |
@@ -15,36 +15,36 @@ |
||
15 | 15 | |
16 | 16 | final class Payment extends Response |
17 | 17 | { |
18 | - /** |
|
19 | - * @var \DOMElement |
|
20 | - */ |
|
21 | - protected $PaymentId; |
|
22 | - |
|
23 | - /** |
|
24 | - * Payment constructor |
|
25 | - * |
|
26 | - * @param string $paymentid |
|
27 | - */ |
|
28 | - public function __construct($paymentid) |
|
29 | - { |
|
30 | - parent::__construct(); |
|
31 | - |
|
32 | - $this->setElementValue('StatusCode', 0); |
|
33 | - $this->setElementValue('StatusDetail', 'checked'); |
|
34 | - |
|
35 | - $this->create_PaymentId($paymentid); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Create PaymentId node |
|
40 | - * |
|
41 | - * @param string $paymentid |
|
42 | - */ |
|
43 | - public function create_PaymentId($paymentid) |
|
44 | - { |
|
45 | - if (isset($this->PaymentId)) return; |
|
46 | - |
|
47 | - $this->PaymentId = self::createElement('PaymentId', $paymentid); |
|
48 | - $this->Response->appendChild($this->PaymentId); |
|
49 | - } |
|
18 | + /** |
|
19 | + * @var \DOMElement |
|
20 | + */ |
|
21 | + protected $PaymentId; |
|
22 | + |
|
23 | + /** |
|
24 | + * Payment constructor |
|
25 | + * |
|
26 | + * @param string $paymentid |
|
27 | + */ |
|
28 | + public function __construct($paymentid) |
|
29 | + { |
|
30 | + parent::__construct(); |
|
31 | + |
|
32 | + $this->setElementValue('StatusCode', 0); |
|
33 | + $this->setElementValue('StatusDetail', 'checked'); |
|
34 | + |
|
35 | + $this->create_PaymentId($paymentid); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Create PaymentId node |
|
40 | + * |
|
41 | + * @param string $paymentid |
|
42 | + */ |
|
43 | + public function create_PaymentId($paymentid) |
|
44 | + { |
|
45 | + if (isset($this->PaymentId)) return; |
|
46 | + |
|
47 | + $this->PaymentId = self::createElement('PaymentId', $paymentid); |
|
48 | + $this->Response->appendChild($this->PaymentId); |
|
49 | + } |
|
50 | 50 | } |
@@ -41,7 +41,9 @@ |
||
41 | 41 | */ |
42 | 42 | public function create_CancelDate($canceldate) |
43 | 43 | { |
44 | - if (isset($this->CancelDate)) return; |
|
44 | + if (isset($this->CancelDate)) { |
|
45 | + return; |
|
46 | + } |
|
45 | 47 | |
46 | 48 | $this->CancelDate = self::createElement('CancelDate', $canceldate); |
47 | 49 | $this->Response->appendChild($this->CancelDate); |
@@ -15,35 +15,35 @@ |
||
15 | 15 | |
16 | 16 | final class Cancel extends Response |
17 | 17 | { |
18 | - /** |
|
19 | - * @var \DOMElement |
|
20 | - */ |
|
21 | - protected $CancelDate; |
|
22 | - |
|
23 | - /** |
|
24 | - * Cancel constructor |
|
25 | - * |
|
26 | - * @param string $orderdate |
|
27 | - */ |
|
28 | - public function __construct($canceldate) { |
|
29 | - parent::__construct(); |
|
30 | - |
|
31 | - $this->setElementValue('StatusCode', 0); |
|
32 | - $this->setElementValue('StatusDetail', 'checked'); |
|
33 | - |
|
34 | - $this->create_CancelDate($canceldate); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Create CancelDate node |
|
39 | - * |
|
40 | - * @param string $canceldate |
|
41 | - */ |
|
42 | - public function create_CancelDate($canceldate) |
|
43 | - { |
|
44 | - if (isset($this->CancelDate)) return; |
|
45 | - |
|
46 | - $this->CancelDate = self::createElement('CancelDate', $canceldate); |
|
47 | - $this->Response->appendChild($this->CancelDate); |
|
48 | - } |
|
18 | + /** |
|
19 | + * @var \DOMElement |
|
20 | + */ |
|
21 | + protected $CancelDate; |
|
22 | + |
|
23 | + /** |
|
24 | + * Cancel constructor |
|
25 | + * |
|
26 | + * @param string $orderdate |
|
27 | + */ |
|
28 | + public function __construct($canceldate) { |
|
29 | + parent::__construct(); |
|
30 | + |
|
31 | + $this->setElementValue('StatusCode', 0); |
|
32 | + $this->setElementValue('StatusDetail', 'checked'); |
|
33 | + |
|
34 | + $this->create_CancelDate($canceldate); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Create CancelDate node |
|
39 | + * |
|
40 | + * @param string $canceldate |
|
41 | + */ |
|
42 | + public function create_CancelDate($canceldate) |
|
43 | + { |
|
44 | + if (isset($this->CancelDate)) return; |
|
45 | + |
|
46 | + $this->CancelDate = self::createElement('CancelDate', $canceldate); |
|
47 | + $this->Response->appendChild($this->CancelDate); |
|
48 | + } |
|
49 | 49 | } |
@@ -42,7 +42,9 @@ |
||
42 | 42 | */ |
43 | 43 | public function create_OrderDate($orderdate) |
44 | 44 | { |
45 | - if (isset($this->OrderDate)) return; |
|
45 | + if (isset($this->OrderDate)) { |
|
46 | + return; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | $this->OrderDate = self::createElement('OrderDate', $orderdate); |
48 | 50 | $this->Response->appendChild($this->OrderDate); |
@@ -15,36 +15,36 @@ |
||
15 | 15 | |
16 | 16 | final class Confirm extends Response |
17 | 17 | { |
18 | - /** |
|
19 | - * @var \DOMElement |
|
20 | - */ |
|
21 | - protected $OrderDate; |
|
22 | - |
|
23 | - /** |
|
24 | - * Confirm constructor |
|
25 | - * |
|
26 | - * @param string $orderdate |
|
27 | - */ |
|
28 | - public function __construct($orderdate) |
|
29 | - { |
|
30 | - parent::__construct(); |
|
31 | - |
|
32 | - $this->setElementValue('StatusCode', 0); |
|
33 | - $this->setElementValue('StatusDetail', 'checked'); |
|
34 | - |
|
35 | - $this->create_OrderDate($orderdate); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Create OrderDate node |
|
40 | - * |
|
41 | - * @param string $orderdate |
|
42 | - */ |
|
43 | - public function create_OrderDate($orderdate) |
|
44 | - { |
|
45 | - if (isset($this->OrderDate)) return; |
|
46 | - |
|
47 | - $this->OrderDate = self::createElement('OrderDate', $orderdate); |
|
48 | - $this->Response->appendChild($this->OrderDate); |
|
49 | - } |
|
18 | + /** |
|
19 | + * @var \DOMElement |
|
20 | + */ |
|
21 | + protected $OrderDate; |
|
22 | + |
|
23 | + /** |
|
24 | + * Confirm constructor |
|
25 | + * |
|
26 | + * @param string $orderdate |
|
27 | + */ |
|
28 | + public function __construct($orderdate) |
|
29 | + { |
|
30 | + parent::__construct(); |
|
31 | + |
|
32 | + $this->setElementValue('StatusCode', 0); |
|
33 | + $this->setElementValue('StatusDetail', 'checked'); |
|
34 | + |
|
35 | + $this->create_OrderDate($orderdate); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Create OrderDate node |
|
40 | + * |
|
41 | + * @param string $orderdate |
|
42 | + */ |
|
43 | + public function create_OrderDate($orderdate) |
|
44 | + { |
|
45 | + if (isset($this->OrderDate)) return; |
|
46 | + |
|
47 | + $this->OrderDate = self::createElement('OrderDate', $orderdate); |
|
48 | + $this->Response->appendChild($this->OrderDate); |
|
49 | + } |
|
50 | 50 | } |
@@ -15,17 +15,17 @@ |
||
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 | } |