@param $command
@param null $data
@param string $format

@return array|\SimpleXMLElement|string
@throws Exception
430772
public function call($command, $data = NULL, $format = 'xml')
		{
			if ($this->checkStatus()) {
				$request = array(
					'form_params' => [
						'r'             => $this->realm,
						'p'             => $this->password,
						'version'       => $this->version,
						'c'             => $command,
						'output_format' => $format
					]
				);

				if (!empty($data)) {
					$request = array('form_params' => array_merge($request['form_params'], $data));
				}

				$guzzle = new \GuzzleHttp\Client;
				$response = $guzzle->request(
					'POST',
					$this->url,
					$request
				);

				$body = (string)$response->getBody();

				if (empty($body)) {
					throw new Exception("No results");
				}

				if ($body == 'Invalid credentials') {
					throw new Exception('Invalid Credentials');
				}

				if ((int)substr_compare($body, "FAILURE", 0, 7) == 0) {
					$result = explode(":", $body);
					throw new Exception(trim($result[1]));
				}

				if ((int)substr_compare($body, "SUCCESS", 0, 7) == 0) {
					$result = explode(":", $body);

					return $result;
				}

				if ((int)substr_compare($body, "<data>", 0, 6, 1) == 0) return new \SimpleXMLElement($body);
				if ((int)substr_compare($body, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", 0, 38, 1) == 0) return new \SimpleXMLElement($body);

				return $body;
			}

			return FALSE;
		}
606272
private function wrapCommandWithMessageEnvelope($command)
    {
        if ($command instanceof Command) {
            return $command;
        }

        if ($command instanceof Serializable) {
            return new GenericCommand(MessageIdentifier::generate(), $command);
        }

        throw new \InvalidArgumentException('Unsupported data type.');
    }
399069
public function executeCommand($command, array $data = array())
    {
        $this->getGuzzleClient()->setUserAgent(
            self::GUZZLE_EXTENSION_NAME . '/' . self::GUZZLE_EXTENSION_VERSION
        );

        $command = $this->getGuzzleClient()->getCommand($command, $data);

        try {
            $result = $this->getGuzzleClient()->execute($command);
        } catch (BadResponseException $e) {
            $this->response = $e->getResponse();

            try {
                $this->result = $this->response->json();

                return;
            } catch (RuntimeException $e) {
                // Do nothing
            }

            try {
                $this->result = $this->response->xml();

                return;
            } catch (RuntimeException $e) {
                // Do nothing
            }

            return;
        }

        $this->response = $command->getResponse();
        $this->result = $result;
    }
240170
public function validate($name, $data, $format = null)
    {
        if (!is_string($data) && !is_array($data)) {
            throw new Exception("propriedade [ {$name} ] é inválida para tipo [ json ] definido no schema", 400);
        }

        $data = $this->encode($name, $data);

        if ($format) {
            $data = self::applyFormat($format, $data);
        }

        return (string)$data;
    }
94018
protected function executeCommand($command)
    {
        $result = @exec($command, $output, $code);
        $output = implode("\n", $output);

        if ($result === false) {
            throw new Exception("Failed to execute command '$command' with message: [$code] '$output'");
        }

        return $output;
    }
126305
public function serializeWithGroup($data, $format, $group)
    {
        $serializer = $this->evaluator->getSerializer();

        return $serializer->serialize($data, $format, SerializationContext::create()->setGroups([$group]));
    }
769013
public static function parseAndRunCommand($command)
    {
        try {
            list($class, $method, $args) = TaskManager::parseCommand($command);
            if (!class_exists($class)) {
                TaskLoader::loadController($class);
            }

            $obj = new $class();
            if (!method_exists($obj, $method)) {
                throw new TaskManagerException('method ' . $method . ' not found in class ' . $class);
            }

            return call_user_func_array(array($obj, $method), $args);
        } catch (\Exception $e) {
            echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL;
            return false;
        }
    }
574909
protected function applyFormat($format, $data)
    {

        foreach ($format as $key => $value) {
            $meta = array_values(array_filter($this->formatting, function ($item) use ($value) {
                return $item['name'] === $value['function'] ? true : false;
            }));

            if ($meta && !array_key_exists('class', $value)) {
                $data = $this->applyDefaultFormat($value, $meta[0], $data);
            } else {
                $data = $this->applyCustomFormat($value, $data);
            }
        }

        return $data;
    }
1036059
public static function loadString($data, $format = Format::JSON, $options = [])
    {
        // Load a string into the given namespace [or default namespace if not given]
        $class = static::getFormatClass($format);

        return $class::stringToStruct($data, $options);
    }
57178
protected function call($command, $params, $data = [], $options = [])
    {
        $uri = $this->getRequestURI($command);
        $body = $this->getRequestBody($params, $data, $options);
        $xml = $this->client->post($uri, $body); // Make the request to web service
        return $this->factory->createResponse($xml, $this->module, $command);
    }
114061
public function getString($command, $target = null, $value = null)
    {
        $result = $this->doExecute($command, $target, $value);

        if (!preg_match('/^OK,/', $result)) {
            throw new Exception("Unexpected response from Selenium server : ".$result);
        }

        return strlen($result) > 3 ? substr($result, 3) : '';
    }
1311479
public void execRun(String command) throws IOException, PHPException {
	    writeCommand("R" + command);
	    phpConsoleLogger.write(command);
		String readLine = readLine();
        phpConsoleLogger.read(readLine);
		
	}
934413
public function execute($command, $params = null)
    {
        $url = $command;

        if (substr($url, -1) !== '/') {
            $url .= '/';
        }

        if ($params) {
            $parameters = array();
            foreach ($params as $k => $v) {
                if (strlen($v)) {
                    $parameters[] = urlencode($k) . '=' . urlencode($v);
                } else {
                    $parameters[] = urlencode($k);
                }
            }
            $url .= '?' . implode('&', $parameters);
        }

        try {
            $response = $this->client->get($url);
        } catch (\Exception $e) {
            return null;
        }
        $this->checkError($response, $url);

        return $response->getBody();
    }
869664
public function beforeCommand(Event $event, Command $command)
    {
        $parameters = $command->parseParameters([], ['h' => 'help']);

        if (
            count($parameters) < ($command->getRequiredParams() + 1) ||
            $command->isReceivedOption(['help', 'h', '?']) ||
            in_array($command->getOption(1), ['help', 'h', '?'])
        ) {
            $command->getHelp();

            return false;
        }

        if( !defined('BASE_PATH') ) {
            throw new CommandsException('Commands need a BASE_PATH constant defined.');
        }

        if ($command->canBeExternal() == false) {
            $path = $command->getOption('directory');
            if (!file_exists($path.'.phalcon')) {
                throw new CommandsException('This command should be invoked inside a Phalcon project directory.');
            }
        }

        return true;
    }
419749
public function getImage(string $format = null) : string
    {
        if (!$format) {
            $format = $this->instance->getImageFormat();
        }
        switch (strtolower($format)) {
            case 'jpg':
            case 'jpeg':
                $this->instance->setImageFormat('jpg');
                break;
            case 'bitmap':
            case 'bmp':
                $this->instance->setImageFormat('bmp');
                break;
            case 'png':
                $this->instance->setImageFormat('png');
                break;
            case 'gif':
                $this->instance->setImageFormat('gif');
                break;
            case 'webp':
                $this->instance->setImageFormat('webp');
                break;
            default:
                throw new ImageException('Unsupported format');
        }
        return $this->instance->getImageBlob();
    }
485377
public static function arrayToXml($data, $root = null, $level = 1, $format = true)
    {
        if (empty($root)) {
            $root = config('df.xml_root', 'dfapi');
        }

        return '<?xml version="1.0" ?>' . static::arrayToXmlInternal($data, $root, $level, $format);
    }
1159864
public function post($command, $params = null, $postcontenttype = 'application/json')
    {
        $url = $command;

        $headers = array('Content-Type' => $postcontenttype);

        $content = $params;
        if ($postcontenttype == 'application/json') {
            $content = json_encode($params);
        }

        try {
            $response = $this->client->post($url, ['headers' => $headers, 'body' => $content]);
        } catch (\Exception $e) {
            return null;
        }
        $this->checkError($response, $url);

        return $response->getBody();
    }