Esempio n. 1
0
 public static function print_blue($msg, $place_holders = array())
 {
     $msg .= PHP_EOL;
     print tools::color_msg(array($msg, $place_holders), tools::COLOR_BLUE);
 }
Esempio n. 2
0
 /**
  * Saves an item into a txt file. The file content has a ini structure.
  *
  * @param String $file_name
  *   The name of the file which the retrieved content will be saved into.
  */
 private function save_retrieved_result($file_name, $file_extension = 'txt')
 {
     $file_full_path = $this->folders['dados'] . "/consulta/{$file_name}.{$file_extension}";
     $item = json_decode($this->response_body_json, true);
     $item['http_code'] = $this->response_code;
     try {
         $writer = $this->container['ini_writer'];
         $writer->toFile($file_full_path, (array) $item, $this->container['ini_writer_lock']);
         tools::print_green("Consulta foi salva em %file_full_path", array('%file_full_path' => $file_full_path));
     } catch (Exception $e) {
         $this->log("Nao foi possivel salvar a consulta em {$file_full_path}.", 'red');
     }
 }
Esempio n. 3
0
 /**
  * Performs validation on passed arguments.
  *
  * @param Integer $command_arguments_qty_expected
  *   Number of arguments expected after the expected parameters.
  */
 private function check_command_arguments($command_arguments_qty_expected = 1)
 {
     $command_type = $this->command_type;
     $command_parameters = $this->command_parameters;
     $command_arguments_qty_sent = $this->command_arguments_qty_sent;
     if ($command_arguments_qty_expected !== $command_arguments_qty_sent) {
         throw new Exception(tools::print_yellow("'{$command_type} {$command_parameters}' requer {$command_arguments_qty_expected} argumento(s). Foi(ram) enviado(s) {$command_arguments_qty_sent}."));
     }
 }