/** * Add another to a call bridge * * @param caller -> PhoneNumber * @param callee -> PhoneNumber * @param args -> Call's arguments (see in function) */ public function callParty($caller, $callee, $args) { $new_call = Call::create($caller, $callee, $this->id, $args); $this->calls++; return Constructor::Make($this, $data->get()); }
/** * The call factory * * @param string $cmd The command string to be executed * @param string $path The working directory * @return Call */ protected function doCreateCall($cmd, $path) { return Call::create($cmd, $path); }
/** * Create a call to the Git binary for later execution * * @param string $path The full path to the Git repository * @param string $command The Git command, e.g. show, commit or add * @param array $arguments The command arguments * @return Call */ public function createGitCall($path, $command, array $arguments) { $handleArg = function ($key, $value) { $key = ltrim($key, '-'); if (strlen($key) == 1 || is_numeric($key)) { $arg = sprintf('-%s', escapeshellarg($key)); if ($value !== null) { $arg .= ' ' . escapeshellarg($value); } } else { $arg = sprintf('--%s', escapeshellarg($key)); if ($value !== null) { $arg .= '=' . escapeshellarg($value); } } return $arg; }; if (!self::isWindows()) { $binary = escapeshellcmd($this->path); } else { $binary = $this->path; } if (!empty($command)) { $command = escapeshellarg($command); } $args = array(); $files = array(); $fileMode = false; foreach ($arguments as $k => $v) { if ($v === '--' || $k === '--') { $fileMode = true; continue; } if (is_int($k)) { if (strpos($v, '-') === 0) { $args[] = $handleArg($v, null); } else { if ($fileMode) { $files[] = escapeshellarg($v); } else { $args[] = escapeshellarg($v); } } } else { if (strpos($k, '-') === 0) { $args[] = $handleArg($k, $v); } } } $cmd = trim(sprintf('%s %s %s', $binary, $command, implode(' ', $args))); if (count($files) > 0) { $cmd .= ' -- ' . implode(' ', $files); } $call = Call::create($cmd, $path); return $call; }