opensrs\Request::process PHP Method

process() public method

Process an OpenSRS Request.
public process ( string $format = '', string $data = '' )
$format string input format (xml, json, array)
$data string data
    public function process($format = '', $data = '')
    {
        if (empty($data)) {
            throw new Exception('OSRS Error - No data found.');
            return;
        }
        $dataArray = array();
        switch (strtolower($format)) {
            case 'array':
                $dataArray = $data;
                break;
            case 'json':
                $json = str_replace('\\"', '"', $data);
                //  Replace  \"  with " for JSON that comes from Javascript
                $dataArray = json_decode($json, true);
                break;
            case 'yaml':
                $dataArray = Spyc::YAMLLoad($data);
                break;
            default:
                $dataArray = $data;
        }
        // Convert associative array to object
        $dataObject = $this->array2object($dataArray);
        $classCall = null;
        $classCall = RequestFactory::build($dataObject->func, $format, $dataObject);
        return $classCall;
    }

Usage Example

コード例 #1
0
 /**
  * Valid submission should complete with no
  * exception thrown.
  *
  *
  * @group validsubmission
  */
 public function testValidLiveSubmission()
 {
     $data = array('func' => 'lookupGetDomain', 'attributes' => array('domain' => 'phptest' . time() . '.com', 'type' => 'all_info'));
     $request = new Request();
     $ns = $request->process('array', $data);
     $this->assertTrue($ns instanceof GetDomain);
     $this->assertTrue($ns->resultRaw['is_success'] == 1);
 }
All Usage Examples Of opensrs\Request::process