data = $value;
if(is_array($this->data))
{
$this->errorAnalyse();
}
}
/**
* @access private
*
*/
// This function analyse the data for error.
// If data consists of Error string it fills the variables $errorCode,$errorClass,$errorMsg $errorLevel and $error.
function errorAnalyse()
{
foreach($this->data as $key => $value)
{
if ($key == "faultstring")
{
$error = array();
$counter = 1;
$start = 0;
while($pos = strpos($value,$this->seperator,$start))
{
$error[$counter] = substr($value,$start,$pos-$start);
$start = $pos+strlen($this->seperator);
$counter = $counter+1;
}
$this->errorCode = $error[1];
$this->errorClass = $error[2];
$this->errorMsg = $error[3];
$this->errorLevel = $error[4];
$this->error = true;
}
}
}
/**
* This function returns true/false depending upon whether data is an error string or not.
*
* @return boolean
*
*/
function isError()
{
return $this->error;
}
/**
* This function returns the data if no error occured .
*
* @return Any
*
*/
function getResult()
{
if(!$this->error)
{
return $this->data;
}
else
{
return "Error Occured.
Access Member Variables of the Response class for Error Description
";
}
}
/**
* This fuction print the Error in proper format.
*
* @return void
*
*/
function printError()
{
if($this->error)
{
print "Error Code:
" . $this->errorCode . "
";
print "Error Class:
" . $this->errorClass. "
";
print "Error Description:
" . $this->errorMsg . "
";
print "Error Level:
" . $this->errorLevel . "
";
}
else
{
print "No Error: Call printData(\$dataToPrint) to print Result
";
}
}
/**
* This fuction print the passed data in proper format.
*
* @return void
* @param string Data to print.
*
*/
function printData($dataToPrint)
{
if(!$this->error)
{
if(is_array($dataToPrint))
{
foreach($dataToPrint as $key => $value)
{
if(is_array($value))
{
$this->printData($value);
}
else
{
print "$key ---> $value
";
}
}
}
else
{
print "$dataToPrint
";
}
}
else
{
print "Error Occured: Call printError() to print Error
";
}
}
}
?>