本文整理汇总了PHP中Console::text方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::text方法的具体用法?PHP Console::text怎么用?PHP Console::text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console::text方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
$temp = [];
foreach (MangaSourceList::getInstance()->getAllowedSourceList() as $src_key => $src_data) {
$temp[] = Console::text($src_key, 0, ConsoleColors::COLOR_CYAN, true);
}
$blockText .= join(', ', $temp);
Console::writeMultiline($blockText, MANGA_SCRAPPER_TAB_STR . $emptyPaddedStr, '', true);
# ====================================================================
# By: anjan @ Nov 06, 2015 12:15 PM
# ====================================================================
# --url
# ====================================================================
Console::text(__pad_space_right("--url", $paramPadLength), 1);
$blockText = 'Accepts an url to manga chapters list or a specific chapter. If a valid manga chapter list url is specified, then the source, and slug param is ignored. Also, if the url is for a chapter, in addition to source and slug, action and chapter-ids params are ignored as well.';
Console::writeMultiline($blockText, MANGA_SCRAPPER_TAB_STR . $emptyPaddedStr, '', true);
/*********************************************************************
* By: Anjan @ Nov 06, 2015 5:13 PM
*********************************************************************
* Available actions
*********************************************************************/
Console::emptyLines(1);
consoleLinePurple('List of supported actions -', 2);
$actionKeyLengths = array();
foreach (ArgumentsList::getActionList() as $key => $data) {
$actionKeyLengths[] = strlen($key);
}
$maxkeyLen = max($actionKeyLengths) + 2 * strlen(MANGA_SCRAPPER_TAB_STR);
foreach (ArgumentsList::getActionList() as $key => $data) {
Console::text(__pad_space_right(MANGA_SCRAPPER_TAB_STR . $key . MANGA_SCRAPPER_TAB_STR, $maxkeyLen), 0, ConsoleColors::COLOR_CYAN);
Console::writeMultiline($data['desc'] . ($data['default'] ? Console::text(' [default]', 0, ConsoleColors::COLOR_RED, true) : ''), __pad_space_right('', $maxkeyLen), '', true);
}
Console::emptyLines(1);
示例2: log
/**
* Print the text
*
* @param string $text The text to print
* @param string|array|boolean $color The color or options for display
* @param bool|string $auto_br
*/
public static function log($text, $color = null, $auto_br = true)
{
echo Console::text($text, $color, $auto_br);
}
示例3: handleError
/**
* Register or run error
*
* @param string $type
* @param callable $route
* @throws \InvalidArgumentException
* @throws \Exception
*/
public function handleError($type, $route = null)
{
if (!isset($this->injectors['errors'][$type])) {
throw new \InvalidArgumentException('Unknown error type "' . $type . '" to call');
}
if (is_string($route) && class_exists($route) || $route instanceof \Closure) {
// Set error handle
$this->injectors['errors'][$type][2] = $route;
} else {
if (!$this->injectors['exception'] && $route instanceof \Exception) {
// Not handle exception and throw it
throw $route;
} else {
// Clean the output buffer
ob_get_level() && ob_clean();
// Check handle route and run it
if (empty($this->injectors['errors'][$type][2]) || !$this->router->run($this->injectors['errors'][$type][2], array('error' => array('type' => $type, 'error' => $route, 'message' => $this->injectors['errors'][$type])))) {
/**
* Get error information
*/
$error = $route instanceof \Exception ? $route : null;
$title = $error ? $error->getMessage() : $this->injectors['errors'][$type][1];
$code = $this->injectors['errors'][$type][0];
$message = $route ? $error ? $error->getFile() . ' [' . $error->getLine() . ']' : (string) $route : '';
if ($this->injectors['cli']) {
// Cli error show
$this->halt($code, Console::text('[' . $title . '] ' . ($message ? $message : '"' . $this->input->path() . '"') . ' ', 'redbg') . "\n" . ($this->injectors['debug'] && $error ? Console::text("\n[Error]\n", "yellow") . $error . "\n" : ''));
} else {
// Http error show
$this->output->status($this->injectors['errors'][$type][0]);
if ($this->injectors['debug']) {
// Debug error show
$this->renderView('Error', array('title' => $title, 'message' => $message ? $message : 'Could not ' . $this->input->method() . ' ' . $this->input->path(), 'stacks' => $this->injectors['debug'] && $error ? $error->getTraceAsString() : null));
} else {
// Normal error show
$this->renderView('Error', array('title' => $title, 'message' => $message ? $message : 'Could not ' . $this->input->method() . ' ' . $this->input->path()));
}
$this->stop();
}
}
}
}
}