Passed
Push — master ( 1728d3...233bc5 )
by Dmitry
01:50
created
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 = 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
 }
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 = 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
 }
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 = 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
 }
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 = 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
 }
Please login to merge, or discard this patch.
src/Provider31/Response.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -16,96 +16,96 @@  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
         self::loadXML(self::TEMPLATE);
44 44
 
45 45
         $this->Response = $this->firstChild;
46 46
         $this->setElementValue('DateTime', date('Y-m-d\TH:i:s', time()));
47
-    }
48
-
49
-    /**
50
-     *      Create new element node
51
-     *
52
-     *      @param string $name
53
-     *      @param string $value (optional)
54
-     */
55
-    public function createElement($name, $value=NULL)
56
-    {
47
+        }
48
+
49
+        /**
50
+         *      Create new element node
51
+         *
52
+         *      @param string $name
53
+         *      @param string $value (optional)
54
+         */
55
+        public function createElement($name, $value=NULL)
56
+        {
57 57
         return parent::createElement($name, $value);
58
-    }
59
-
60
-    /**
61
-     *      Create new node attribute
62
-     *
63
-     *      @param string $name
64
-     *      @param string $value
65
-     */
66
-    public function create_attr($name, $value)
67
-    {
58
+        }
59
+
60
+        /**
61
+         *      Create new node attribute
62
+         *
63
+         *      @param string $name
64
+         *      @param string $value
65
+         */
66
+        public function create_attr($name, $value)
67
+        {
68 68
         return new DOMAttr($name, $value);
69
-    }
70
-
71
-    /**
72
-     *      Set node value
73
-     *
74
-     *      @param string $name
75
-     *      @param string $value
76
-     */
77
-    public function setElementValue($name, $value)
78
-    {
69
+        }
70
+
71
+        /**
72
+         *      Set node value
73
+         *
74
+         *      @param string $name
75
+         *      @param string $value
76
+         */
77
+        public function setElementValue($name, $value)
78
+        {
79 79
         foreach ($this->Response->childNodes as $child)
80 80
         {
81
-            if ($child->nodeName == $name)
82
-            {
81
+                if ($child->nodeName == $name)
82
+                {
83 83
                 $child->nodeValue = $value;
84
-            }
84
+                }
85
+        }
85 86
         }
86
-    }
87
-
88
-    /**
89
-     *      Dumps response into a string
90
-     *
91
-     *      @return string XML
92
-     */
93
-    public function friendly()
94
-    {
87
+
88
+        /**
89
+         *      Dumps response into a string
90
+         *
91
+         *      @return string XML
92
+         */
93
+        public function friendly()
94
+        {
95 95
         $this->encoding = 'UTF-8';
96 96
         $this->formatOutput = true;
97 97
         //$this->save('/tmp/test1.xml');
98 98
 
99 99
         return $this->saveXML(NULL, LIBXML_NOEMPTYTAG);
100
-    }
101
-
102
-    /**
103
-     *      Send response
104
-     *
105
-     *      @param array $options
106
-     */
107
-    public function out($options)
108
-    {
100
+        }
101
+
102
+        /**
103
+         *      Send response
104
+         *
105
+         *      @param array $options
106
+         */
107
+        public function out($options)
108
+        {
109 109
         $this->sign($options);
110 110
 
111 111
         Log::instance()->debug('response sends: ');
@@ -115,62 +115,62 @@  discard block
 block discarded – undo
115 115
         header("Content-Type: text/xml; charset=utf-8");
116 116
         echo $this->friendly();
117 117
         exit;
118
-    }
119
-
120
-    /**
121
-     *      Add Sign (if hasn't yet done)
122
-     *
123
-     *      @param array $options
124
-     */
125
-    protected function sign($options)
126
-    {
118
+        }
119
+
120
+        /**
121
+         *      Add Sign (if hasn't yet done)
122
+         *
123
+         *      @param array $options
124
+         */
125
+        protected function sign($options)
126
+        {
127 127
         if (isset($this->Sign)) return;
128 128
 
129 129
         if (isset($options['UseSign']) && ($options['UseSign'] === true))
130 130
         {
131
-            $this->Sign = self::createElement('Sign');
132
-            $this->Response->appendChild($this->Sign);
131
+                $this->Sign = self::createElement('Sign');
132
+                $this->Response->appendChild($this->Sign);
133 133
 
134
-            $sign = $this->generate_sign($options);
134
+                $sign = $this->generate_sign($options);
135 135
 
136
-            $this->Sign->nodeValue = $sign;
136
+                $this->Sign->nodeValue = $sign;
137
+        }
137 138
         }
138
-    }
139
-
140
-    /**
141
-     *      Generate signature of response
142
-     *
143
-     *      @param array $options
144
-     *      @return string
145
-     */
146
-    public function generate_sign($options)
147
-    {
139
+
140
+        /**
141
+         *      Generate signature of response
142
+         *
143
+         *      @param array $options
144
+         *      @return string
145
+         */
146
+        public function generate_sign($options)
147
+        {
148 148
         if ( ! isset($options['ProviderPKey']))
149 149
         {
150
-            Log::instance()->error('The parameter ProviderPKey is not set!');
151
-            return null;
150
+                Log::instance()->error('The parameter ProviderPKey is not set!');
151
+                return null;
152 152
         }
153 153
         try
154 154
         {
155
-            $pkeyid = (new Key())->get($options['ProviderPKey'], 'private');
155
+                $pkeyid = (new Key())->get($options['ProviderPKey'], 'private');
156 156
         }
157 157
         catch (\Exception $e)
158 158
         {
159
-            return null;
159
+                return null;
160 160
         }
161 161
 
162 162
         $pr_key = openssl_pkey_get_private($pkeyid);
163 163
         if ($pr_key === FALSE)
164 164
         {
165
-            Log::instance()->error('Can not extract the private key from certificate!');
166
-            return null;
165
+                Log::instance()->error('Can not extract the private key from certificate!');
166
+                return null;
167 167
         }
168 168
         if (openssl_sign($this->friendly(), $sign, $pr_key) === FALSE)
169 169
         {
170
-            Log::instance()->error('Can not generate signature!');
171
-            return null;
170
+                Log::instance()->error('Can not generate signature!');
171
+                return null;
172 172
         }
173 173
 
174 174
         return strtoupper(bin2hex($sign));
175
-    }
175
+        }
176 176
 }
Please login to merge, or discard this patch.