Skip to content

Commit a8aa577

Browse files
committed
httpsupp minor refactoring and adding docblocks
1 parent b7b944b commit a8aa577

File tree

1 file changed

+101
-42
lines changed

1 file changed

+101
-42
lines changed

ToolkitApi/httpsupp.php

Lines changed: 101 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,21 @@
2323
* Options +ExecCGI
2424
* </Directory>
2525
*
26+
* @todo define common transport class/interface extended/implemented by all transports. They have much in common.
27+
*
2628
* @package ToolkitApi
2729
*/
2830
class httpsupp
2931
{
30-
// @todo define common transport class/interface extended/implemented by all transports
31-
// They have much in common.
32-
33-
protected $last_errorcode = ''; // SQL State
34-
protected $last_errormsg = ''; // SQL Code with message
35-
36-
protected $_ipc = null;
37-
protected $_ctl = null;
38-
protected $_url = null;
39-
protected $_db = null;
40-
protected $_user = null;
41-
protected $_pw = null;
42-
43-
protected $_debug = null; // @todo see what for
32+
protected $last_errorcode;
33+
protected $last_errormsg;
34+
protected $_ipc;
35+
protected $_ctl;
36+
protected $_url;
37+
protected $_db;
38+
protected $_user;
39+
protected $_pw;
40+
protected $_debug;
4441

4542
// parms [$ipc, $ctl, $i5rest, $debug]:
4643
// $ipc - route to XMLSERVICE job (/tmp/xmlibmdb2)
@@ -53,12 +50,19 @@ class httpsupp
5350
// *all - dump XML input/output
5451
public function __construct($ipc='/tmp/xmldb2', $ctl='*sbmjob', $url='http://example.com/cgi-bin/xmlcgi.pgm', $debug='*none')
5552
{
56-
// empty
53+
$this->setIpc($ipc);
54+
$this->setCtl($ctl);
55+
$this->setUrl($url);
56+
$this->_debug = $debug;
5757
}
58-
59-
public function send($xmlIn,$outSize)
58+
59+
/**
60+
* @param $xmlIn
61+
* @param $outSize
62+
* @return string
63+
*/
64+
public function send($xmlIn, $outSize)
6065
{
61-
// http POST parms
6266
$clobIn = $xmlIn;
6367
$clobOut = $outSize;
6468
$postdata = http_build_query(
@@ -102,69 +106,104 @@ public function send($xmlIn,$outSize)
102106

103107
return $clobOut;
104108
}
105-
109+
110+
/**
111+
* @return string
112+
*/
106113
public function getErrorCode()
107114
{
108-
109115
return $this->last_errorcode;
110116
}
111-
117+
118+
/**
119+
* @return string
120+
*/
112121
public function getErrorMsg()
113122
{
114-
115123
return $this->last_errormsg;
116124
}
117-
125+
126+
/**
127+
* @param $errorCode
128+
*/
118129
protected function setErrorCode($errorCode)
119130
{
120131
$this->last_errorcode = $errorCode;
121132
}
122-
133+
134+
/**
135+
* @param $errorMsg
136+
*/
123137
protected function setErrorMsg($errorMsg)
124138
{
125139
$this->last_errormsg = $errorMsg;
126140
}
127-
141+
142+
/**
143+
* @param $ipc
144+
*/
128145
public function setIpc($ipc)
129146
{
130147
$this->_ipc = $ipc;
131148
}
132-
149+
150+
/**
151+
* @return null
152+
*/
133153
public function getIpc()
134154
{
135155
return $this->_ipc;
136156
}
137-
157+
158+
/**
159+
* @param string $ctl
160+
*/
138161
public function setCtl($ctl = '')
139162
{
140163
$this->_ctl = $ctl;
141164
}
142-
165+
166+
/**
167+
* @return null
168+
*/
143169
public function getCtl()
144170
{
145171
return $this->_ctl;
146172
}
147-
173+
174+
/**
175+
* @param string $url\
176+
*/
148177
public function setUrl($url = '')
149178
{
150179
$this->_url = $url;
151180
}
152-
181+
182+
/**
183+
* @return null
184+
*/
153185
public function getUrl()
154186
{
155187
return $this->_url;
156188
}
157189

158-
// @todo shared transport method
190+
/**
191+
*
192+
* @todo shared transport method
193+
*
194+
* @param $xml
195+
* @return string
196+
*/
159197
public function driverJunkAway($xml)
160198
{
161199
// trim blanks
162200
$clobOut = trim($xml);
163-
if (! $clobOut) return $clobOut;
201+
if (!$clobOut) return $clobOut;
164202

165203
// result set has extra data (junk)
166204
$fixme = '</script>';
167205
$pos = strpos($clobOut,$fixme);
206+
168207
if ($pos > -1) {
169208
$clobOut = substr($clobOut,0,$pos+strlen($fixme));
170209
} else { // maybe error/performance report
@@ -175,40 +214,60 @@ public function driverJunkAway($xml)
175214
$clobOut = substr($clobOut,0,$pos+strlen($fixme));
176215
}
177216
}
217+
178218
return $clobOut;
179219
}
180-
220+
221+
/**
222+
* @param string $db
223+
* @param $user
224+
* @param $pw
225+
* @param array $options
226+
* @return $this
227+
*/
181228
public function http_connect($db = '*LOCAL', $user, $pw, $options=array())
182229
{
183-
if (!$db) {
184-
$db = '*LOCAL';
185-
}
186-
187230
$this->_db = $db;
188231
$this->_user = $user;
189232
$this->_pw = $pw;
190233

191234
return $this;
192235
}
193-
236+
237+
/**
238+
* @param string $database
239+
* @param $user
240+
* @param $password
241+
* @param null $options
242+
* @return httpsupp
243+
*/
194244
public function connect($database = '*LOCAL', $user, $password, $options = null)
195245
{
196246
return $this->http_connect($database, $user, $password, $options = array());
197247

198248
}
199-
249+
250+
/**
251+
* @return null
252+
*/
200253
protected function getUser()
201254
{
202255
return $this->_user;
203256
}
204-
257+
258+
/**
259+
* @return null
260+
*/
205261
protected function getPw()
206262
{
207263
return $this->_pw;
208264
}
209-
265+
266+
/**
267+
* @return null
268+
*/
210269
protected function getDb()
211270
{
212271
return $this->_db;
213272
}
214-
}
273+
}

0 commit comments

Comments
 (0)