Passed
Push — master ( 76cacd...120832 )
by Dmitry
01:58
created
src/Key.php 1 patch
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.
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/Response/Check.php 1 patch
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.
src/Provider31/Response/Cancel.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,35 +15,35 @@
 block discarded – undo
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 = $this->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 = $this->createElement('CancelDate', $canceldate);
47
+                $this->Response->appendChild($this->CancelDate);
48
+        }
49 49
 }
Please login to merge, or discard this patch.
src/Provider31/Response/Confirm.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
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 = $this->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 = $this->createElement('OrderDate', $orderdate);
48
+                $this->Response->appendChild($this->OrderDate);
49
+        }
50 50
 }
Please login to merge, or discard this patch.
src/Provider31/Response/Payment.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
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 = $this->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 = $this->createElement('PaymentId', $paymentid);
48
+                $this->Response->appendChild($this->PaymentId);
49
+        }
50 50
 }
Please login to merge, or discard this patch.
src/Provider31/Request.php 1 patch
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 \EasyPay\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 \EasyPay\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 \EasyPay\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.
src/OpenSSL.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -4,76 +4,76 @@
 block discarded – undo
4 4
 
5 5
 class OpenSSL
6 6
 {
7
-    public function __construct() {}
7
+        public function __construct() {}
8 8
 
9
-    /**
10
-     *      verify signature of xml
11
-     *
12
-     *      @param string $xml
13
-     *      @param string $bin_sign
14
-     *      @param resource $pub_key
15
-     *
16
-     *      @return integer result of checking
17
-     */
18
-    public function verify($xml, $bin_sign, $pub_key)
19
-    {
9
+        /**
10
+         *      verify signature of xml
11
+         *
12
+         *      @param string $xml
13
+         *      @param string $bin_sign
14
+         *      @param resource $pub_key
15
+         *
16
+         *      @return integer result of checking
17
+         */
18
+        public function verify($xml, $bin_sign, $pub_key)
19
+        {
20 20
         return @openssl_verify($xml, $bin_sign, $pub_key);
21
-    }
21
+        }
22 22
 
23
-    /**
24
-     *      generate signature of xml
25
-     *
26
-     *      @param string $xml
27
-     *      @param string $sign
28
-     *      @param resource $priv_key
29
-     *
30
-     *      @return bool result of signing
31
-     */
32
-    public function sign($xml, &$sign, $priv_key)
33
-    {
23
+        /**
24
+         *      generate signature of xml
25
+         *
26
+         *      @param string $xml
27
+         *      @param string $sign
28
+         *      @param resource $priv_key
29
+         *
30
+         *      @return bool result of signing
31
+         */
32
+        public function sign($xml, &$sign, $priv_key)
33
+        {
34 34
         return @openssl_sign($xml, $sign, $priv_key);
35
-    }
35
+        }
36 36
 
37
-    /**
38
-     *      get public key
39
-     *
40
-     *      @param mixed $certificate
41
-     *      @return resource
42
-     */
43
-    public function get_pub_key($certificate)
44
-    {
37
+        /**
38
+         *      get public key
39
+         *
40
+         *      @param mixed $certificate
41
+         *      @return resource
42
+         */
43
+        public function get_pub_key($certificate)
44
+        {
45 45
         $pub_key = @openssl_pkey_get_public($certificate);
46 46
         $this->is_key($pub_key);
47 47
 
48 48
         return $pub_key;
49
-    }
49
+        }
50 50
 
51
-    /**
52
-     *      get private key
53
-     *
54
-     *      @param mixed $certificate
55
-     *      @return resource
56
-     */
57
-    public function get_priv_key($certificate)
58
-    {
51
+        /**
52
+         *      get private key
53
+         *
54
+         *      @param mixed $certificate
55
+         *      @return resource
56
+         */
57
+        public function get_priv_key($certificate)
58
+        {
59 59
         $priv_key = @openssl_pkey_get_private($certificate);
60 60
         $this->is_key($priv_key);
61 61
 
62 62
         return $priv_key;
63
-    }
63
+        }
64 64
 
65
-    /**
66
-     *      check key
67
-     *
68
-     *      @param resource $key
69
-     *      @throws Exception\Runtime
70
-     */
71
-    public function is_key($key)
72
-    {
65
+        /**
66
+         *      check key
67
+         *
68
+         *      @param resource $key
69
+         *      @throws Exception\Runtime
70
+         */
71
+        public function is_key($key)
72
+        {
73 73
         if ($key === FALSE)
74 74
         {
75
-            throw new Exception\Runtime('Can not extract key from certificate!', -97);
75
+                throw new Exception\Runtime('Can not extract key from certificate!', -97);
76
+        }
76 77
         }
77
-    }
78 78
 
79 79
 }
Please login to merge, or discard this patch.
src/Provider31/Response.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -17,194 +17,194 @@
 block discarded – undo
17 17
 
18 18
 abstract class Response extends \DomDocument
19 19
 {
20
-    /**
21
-     *      @var string
22
-     *
23
-     */
24
-    const TEMPLATE = '<Response><StatusCode></StatusCode><StatusDetail></StatusDetail><DateTime></DateTime></Response>';
25
-
26
-    /**
27
-     *      @var \DOMNode
28
-     */
29
-    protected $Response;
30
-
31
-    /**
32
-     *      @var \DOMElement
33
-     */
34
-    protected $Sign;
35
-
36
-    /**
37
-     *      Response constructor
38
-     *
39
-     */
40
-    public function __construct()
41
-    {
20
+        /**
21
+         *      @var string
22
+         *
23
+         */
24
+        const TEMPLATE = '<Response><StatusCode></StatusCode><StatusDetail></StatusDetail><DateTime></DateTime></Response>';
25
+
26
+        /**
27
+         *      @var \DOMNode
28
+         */
29
+        protected $Response;
30
+
31
+        /**
32
+         *      @var \DOMElement
33
+         */
34
+        protected $Sign;
35
+
36
+        /**
37
+         *      Response constructor
38
+         *
39
+         */
40
+        public function __construct()
41
+        {
42 42
         parent::__construct('1.0', 'UTF-8');
43 43
 
44 44
         $this->loadXML(self::TEMPLATE);
45 45
 
46 46
         $this->Response = $this->firstChild;
47 47
         $this->set_DateTime();
48
-    }
48
+        }
49 49
 
50
-    /**
51
-     *      Set DateTime element value by current time
52
-     */
53
-    public function set_DateTime()
54
-    {
50
+        /**
51
+         *      Set DateTime element value by current time
52
+         */
53
+        public function set_DateTime()
54
+        {
55 55
         $this->setElementValue('DateTime', date('Y-m-d\TH:i:s', time()));
56
-    }
57
-
58
-    /**
59
-     *      Create new element node
60
-     *
61
-     *      @param string $name
62
-     *      @param string $value (optional)
63
-     */
64
-    public function createElement($name, $value=NULL)
65
-    {
56
+        }
57
+
58
+        /**
59
+         *      Create new element node
60
+         *
61
+         *      @param string $name
62
+         *      @param string $value (optional)
63
+         */
64
+        public function createElement($name, $value=NULL)
65
+        {
66 66
         return parent::createElement($name, $value);
67
-    }
68
-
69
-    /**
70
-     *      Set node value
71
-     *
72
-     *      @param string $name
73
-     *      @param string $value
74
-     */
75
-    public function setElementValue($name, $value)
76
-    {
67
+        }
68
+
69
+        /**
70
+         *      Set node value
71
+         *
72
+         *      @param string $name
73
+         *      @param string $value
74
+         */
75
+        public function setElementValue($name, $value)
76
+        {
77 77
         foreach ($this->Response->childNodes as $child)
78 78
         {
79
-            if ($child->nodeName == $name)
80
-            {
79
+                if ($child->nodeName == $name)
80
+                {
81 81
                 $child->nodeValue = $value;
82
-            }
82
+                }
83
+        }
83 84
         }
84
-    }
85 85
 
86
-    /**
87
-     *      Dumps response into a string
88
-     *
89
-     *      @return string XML
90
-     */
91
-    public function friendly()
92
-    {
86
+        /**
87
+         *      Dumps response into a string
88
+         *
89
+         *      @return string XML
90
+         */
91
+        public function friendly()
92
+        {
93 93
         $this->encoding = 'UTF-8';
94 94
         $this->formatOutput = true;
95 95
 
96 96
         return $this->saveXML(NULL, LIBXML_NOEMPTYTAG);
97
-    }
98
-
99
-    /**
100
-     *      Sign and send response
101
-     *
102
-     *      @param array $options
103
-     */
104
-    public function sign_and_out($options)
105
-    {
97
+        }
98
+
99
+        /**
100
+         *      Sign and send response
101
+         *
102
+         *      @param array $options
103
+         */
104
+        public function sign_and_out($options)
105
+        {
106 106
         $this->sign($options);
107 107
         $this->out_header();
108 108
         $this->out_body($this->friendly());
109
-    }
109
+        }
110 110
 
111
-    /**
112
-     *      Send header
113
-     */
114
-    protected function out_header()
115
-    {
111
+        /**
112
+         *      Send header
113
+         */
114
+        protected function out_header()
115
+        {
116 116
         ob_clean();
117 117
         @header("Content-Type: text/xml; charset=utf-8");
118
-    }
119
-
120
-    /**
121
-     *      Send body
122
-     *
123
-     *      @param string $body
124
-     */
125
-    protected function out_body($body)
126
-    {
118
+        }
119
+
120
+        /**
121
+         *      Send body
122
+         *
123
+         *      @param string $body
124
+         */
125
+        protected function out_body($body)
126
+        {
127 127
         Log::instance()->debug('response sends: ');
128 128
         Log::instance()->debug($body);
129 129
 
130 130
         echo $body;
131
-    }
132
-
133
-    /**
134
-     *      Add Sign (if hasn't yet done)
135
-     *
136
-     *      @param array $options
137
-     */
138
-    protected function sign($options)
139
-    {
131
+        }
132
+
133
+        /**
134
+         *      Add Sign (if hasn't yet done)
135
+         *
136
+         *      @param array $options
137
+         */
138
+        protected function sign($options)
139
+        {
140 140
         if (isset($this->Sign)) return;
141 141
 
142 142
         if (isset($options['UseSign']) && ($options['UseSign'] === true))
143 143
         {
144
-            $this->Sign = $this->createElement('Sign');
145
-            $this->Response->appendChild($this->Sign);
144
+                $this->Sign = $this->createElement('Sign');
145
+                $this->Response->appendChild($this->Sign);
146 146
 
147
-            $sign = $this->generate_sign($options);
147
+                $sign = $this->generate_sign($options);
148 148
 
149
-            $this->Sign->nodeValue = $sign;
149
+                $this->Sign->nodeValue = $sign;
150
+        }
150 151
         }
151
-    }
152 152
 
153
-    /**
154
-     *      Generate signature of response
155
-     *
156
-     *      @param array $options
157
-     *      @return string
158
-     */
159
-    public function generate_sign($options)
160
-    {
153
+        /**
154
+         *      Generate signature of response
155
+         *
156
+         *      @param array $options
157
+         *      @return string
158
+         */
159
+        public function generate_sign($options)
160
+        {
161 161
         try
162 162
         {
163
-            $sign = '';
164
-            $this->check_sign_result(
163
+                $sign = '';
164
+                $this->check_sign_result(
165 165
                 $result = (new OpenSSL())->sign(
166
-                    $this->friendly(),
167
-                    $sign,
168
-                    (new OpenSSL())->get_priv_key($this->get_priv_key($options))
166
+                        $this->friendly(),
167
+                        $sign,
168
+                        (new OpenSSL())->get_priv_key($this->get_priv_key($options))
169 169
                 )
170
-            );
170
+                );
171 171
 
172
-            return strtoupper(bin2hex($sign));
172
+                return strtoupper(bin2hex($sign));
173 173
         }
174 174
         catch (\Exception $e)
175 175
         {
176
-            return null;
176
+                return null;
177
+        }
177 178
         }
178
-    }
179 179
 
180
-    /**
181
-     *      load file with provider private key
182
-     *
183
-     *      @param array $options
184
-     *      @throws Exception\Runtime
185
-     *      @return string
186
-     */
187
-    protected function get_priv_key($options)
188
-    {
180
+        /**
181
+         *      load file with provider private key
182
+         *
183
+         *      @param array $options
184
+         *      @throws Exception\Runtime
185
+         *      @return string
186
+         */
187
+        protected function get_priv_key($options)
188
+        {
189 189
         if ( ! isset($options['ProviderPKey']))
190 190
         {
191
-            throw new \EasyPay\Exception\Runtime('The parameter ProviderPKey is not set!', -94);
191
+                throw new \EasyPay\Exception\Runtime('The parameter ProviderPKey is not set!', -94);
192 192
         }
193 193
 
194 194
         return (new Key())->get($options['ProviderPKey'], 'private');
195
-    }
196
-
197
-    /**
198
-     *      check result of openssl sign
199
-     *
200
-     *      @param bool $result
201
-     *      @throws Exception\Sign
202
-     */
203
-    protected function check_sign_result($result)
204
-    {
195
+        }
196
+
197
+        /**
198
+         *      check result of openssl sign
199
+         *
200
+         *      @param bool $result
201
+         *      @throws Exception\Sign
202
+         */
203
+        protected function check_sign_result($result)
204
+        {
205 205
         if ($result === FALSE)
206 206
         {
207
-            throw new \EasyPay\Exception\Sign('Can not generate signature!', -96);
207
+                throw new \EasyPay\Exception\Sign('Can not generate signature!', -96);
208
+        }
208 209
         }
209
-    }
210 210
 }
Please login to merge, or discard this patch.