@param array  $params
@param string $answerFormat

@return array|object
429660
protected function doRequest($params, $answerFormat = ConnectorInterface::ANSWER_FORMAT_ARRAY)
    {
        $data = [
            'method' => $this->method,
            'params' => $params
        ];

        return $this->connector->doRequest($this->apiName, $data, $answerFormat);
    }
1049234
public function ask(string $prompt, array $validAnswers = [], string $default = null)
    {
        if ($validAnswers) {
            $answers = [];
            foreach ($validAnswers as $v) {
                if ($default && $default === $v) {
                    $answers[] = '[' . $v . ']';
                } else {
                    $answers[] = $v;
                }
            }
            $prompt .= ' (' . implode('/', $answers) . ')';
        }

        $prompt .= ' ';

        if ($this->style) {
            echo $this->formatter->getStartMark($this->style);
        }

        $answer = null;
        while (true) {
            $answer = trim($this->console->readLine($prompt));
            if ($validAnswers) {
                if (in_array($answer, $validAnswers, true)) {
                    break;
                }

                if (trim($answer) === '' && $default) {
                    $answer = $default;
                    break;
                }
                continue;
            }
            break;
        }

        if ($this->style) {
            echo $this->formatter->getClearMark();
        }

        return $answer;
    }
950625
public function parseCustomFormat($format)
    {
        if (isset($this->parsedFormats[$format])) {
            return $this->parsedFormats[$format];
        }

        return $this->parsedFormats[$format] = $this->parseFormat($format);
    }
418958
function toArray($route = null,array $parameters = array(),$format = null) {
        if($format === null){
            $format = $this->defaultFormat;
        }
        if(in_array($format, $this->formatArray)){
            $method = 'formatToArray'.ucfirst($format);
            return $this->$method($route,$parameters);
        }
    }
570804
public function view($params, $optParams = [])
    {
        if (!$params instanceof AccessToken) {
            throw new InvalidParamException(AccessToken::class . ' is required!');
        }
        $class = get_class($params);

        return $this->sendRequest([], [
            'restAction' => 'view',
            'restId' => $params->id,
            'getParams' => $optParams,
        ], function ($response) use ($class) {
            return isset($response->data) ? new $class($response->data) : $response;
        });
    }
920719
public function formatted($isFormatted=null)
    {
        if (isset($isFormatted)) {
            $this->data['formatted'] = $isFormatted;
            return $this;
        }
        
        return isset($this->data['formatted']) ? $this->data['formatted'] : false;
    }
1060236
private function getFormat(array $options)
    {
        if (isset($options[self::PARAM_FORMAT])) {
            return $options[self::PARAM_FORMAT];
        } else {
            return $this->defaultFormat;
        }
    }
311064
public function buildArgsFormat(ArgsFormat $baseFormat = null)
    {
        $formatBuilder = ArgsFormat::build($baseFormat);

        if (!$this->anonymous) {
            $formatBuilder->addCommandName(new CommandName($this->name, $this->aliases));
        }

        $formatBuilder->addOptions($this->getOptions());
        $formatBuilder->addArguments($this->getArguments());

        return $formatBuilder->getFormat();
    }
1161654
public function api($method, $parameters = array(), $format = 'array', $requestMethod = 'get')
    {
        $parameters['timestamp'] = time();
        $parameters['api_id'] = $this->app_id;
        $parameters['random'] = rand(0, 10000);

        if (!array_key_exists('access_token', $parameters) && !is_null($this->access_token)) {
            $parameters['access_token'] = $this->access_token;
        }

        if (!array_key_exists('v', $parameters) && !is_null($this->api_version)) {
            $parameters['v'] = $this->api_version;
        }

        ksort($parameters);

        $sig = '';
        foreach ($parameters as $key => $value) {
            $sig .= $key . '=' . $value;
        }
        $sig .= $this->api_secret;

        $parameters['sig'] = md5($sig);

        if ($method == 'execute' || $requestMethod == 'post') {
            $rs = $this->request(
                $this->getApiUrl($method, $format == 'array' ? 'json' : $format), "POST", $parameters);
        } else {
            $rs = $this->request($this->createUrl(
                $this->getApiUrl($method, $format == 'array' ? 'json' : $format), $parameters));
        }
        return $format == 'array' ? json_decode($rs, true) : $rs;
    }
1071299
public function convertPhpToJavascriptFormat($phpFormat)
    {
        // Converts all the meaningful characters.
        $replacements = self::REPLACEMENTS;

        // Converts all the escaped meaningful characters.
        foreach (self::REPLACEMENTS as $from => $to) {
            $replacements['\\' . $from] = '[' . $from . ']';
        }

        return strtr($phpFormat, $replacements);
    }
1293586
private function format_response($response, $context, $responseformat, $answerid, $options) {

        $convertstudentresponse = file_rewrite_pluginfile_urls($response, 'pluginfile.php',
            $context->id, 'mod_lesson', 'page_responses', $answerid);

        return format_text($convertstudentresponse, $responseformat, $options);
    }
232903
private function extractFields(array $params)
    {
        if (false === $this->issetNotEmpty(self::PARAM_FIELDSETS, $params)) {
            return $this;
        }
        $fields = $params[self::PARAM_FIELDSETS];
        if (!is_array($fields)) {
            throw RestException::invalidQueryParam(self::PARAM_FIELDSETS, 'The field parameter must be an array of entity type keys to fields.');
        }
        foreach ($fields as $entityType => $string) {
            $this->fields[$entityType] = explode(',', $string);
        }
        return $this;
    }
52172
public function getFormulaireGestionDroits($params = array())
    {
        $d                          = new droitsObject();
        $arrayProfilCourant         = $d->getProfilCourantFormulaire();
        $retour                     = "<h1>Gestion des droits ".$arrayProfilCourant['libelle']."</h1>";
        $paramsUrl                  = array();
        $paramsUrl['archiIdProfil'] = $arrayProfilCourant['idProfil'];
        $retour                    .= "<form action='".$this->creerUrl('enregistreDroits', 'adminDroits', $paramsUrl)."' method='POST' enctype='multipart/form-data' name='formDroits'>";
        $arrayListeProfils          = $d->getArrayListeProfils();
        foreach ($arrayListeProfils as $idProfil=>$intitule) {
            $retour .= "<a href='".$this->creerUrl('', 'adminDroits', array('archiIdProfil'=>$idProfil))."'>".$intitule."</a> ";
        }
        $retour                  .= "<br><br>";
        $retour                  .= $d->getFormulaireGestionDroits($params);
        $retour                  .= "<input type='submit' name='submitDroits' value='Enregistrer'>";
        $retour                  .= "</form>";
        $reqUtilisateursCount     = "SELECT 0 FROM utilisateur WHERE idProfil = '".$arrayProfilCourant['idProfil']."'";
        $resUtilisateursCount     = $this->connexionBdd->requete($reqUtilisateursCount);
        $p                        = new paginationObject();
        $nbEnregistrementsParPage = 20;
        $arrayPagination          = $p->pagination(array('nomParamPageCourante'=>'archiPageCouranteVille', 'nbEnregistrementsParPage'=>$nbEnregistrementsParPage, 'nbEnregistrementsTotaux'=>mysql_num_rows($resUtilisateursCount), 'typeLiens'=>'noformulaire'));
        $reqUtilisateurs          = "SELECT nom, prenom, mail FROM utilisateur WHERE idProfil = '".$arrayProfilCourant['idProfil']."'";
        $reqUtilisateurs          = $p->addLimitToQuery($reqUtilisateurs);
        $resUtilisateurs          = $this->connexionBdd->requete($reqUtilisateurs);
        $t                        = new tableau();
        while ($fetchUtilisateurs = mysql_fetch_assoc($resUtilisateurs)) {
            $t->addValue($fetchUtilisateurs['nom']);
            $t->addValue($fetchUtilisateurs['prenom']);
            $t->addValue($fetchUtilisateurs['mail']);
        }
        if (mysql_num_rows($resUtilisateurs)>0) {
            $retour .= "<b>Liste des utilisateurs concernés :</b><br><br>".$arrayPagination['html']."<br>".$t->createTable(3);
        }
        return $retour;
    }
735453
public function getFormattedQuestion($question, $default, array $options)
    {
        if ($this->isList($options)) {
            /**
             * Options list mode
             */
            return $this->getFormattedListQuestion($question, $default, $options);
        } else {
            /**
             * Simple options mode
             */
            return $this->getFormattedSimpleQuestion($question, $default, $options);
        }
    }
720674
protected function fetchResponse($params)
    {
        $qs = http_build_query($params);
        $response = file_get_contents($this->verifyUrl . '?' . $qs);

        return json_decode($response, true);
    }
682702
public function request($method, $url, array $params = [])
    {
        if (!$this->authenticated()) {
            $this->authenticate();
        }

        if (!isset($params['query'])) {
            $params['query'] = [];
        }

        $params['query']['format'] = 'json';

        try {
            $response = $this->getHttpClient()->request($method, $url, $params);
        } catch (RequestException $e) {
            return $e->getResponse();
        }

        return $response;
    }
457361
private function formatParams(array $params) {
        foreach ($params as $key => $value) {
            if (is_array($value)) {
                $params[$key] = implode(',', $value);
            } else if (is_bool($value)) {
                $params[$key] = $value ? 1 : 0;
            }
        }
        return $params;
    }