public function __construct() { parent::__construct(); $this->args = new Arguments(); $this->_userDefinedFlags = new ArgumentBag(); $this->_userDefinedOptions = new ArgumentBag(); }
/** * Initializes the `Table` class. * * There are 3 ways to instantiate this class: * * 1. Pass an array of strings as the first parameter for the column headers * and a 2-dimensional array as the second parameter for the data rows. * 2. Pass an array of hash tables (string indexes instead of numerical) * where each hash table is a row and the indexes of the *first* hash * table are used as the header values. * 3. Pass nothing and use `setHeaders()` and `addRow()` or `setRows()`. * * @param array $headers Headers used in this table. Optional. * @param array $rows The rows of data for this table. Optional. * @param array $footers Footers used in this table. Optional. */ public function __construct(array $headers = null, array $rows = null, array $footers = null) { parent::__construct(); if (!empty($headers)) { // If all the rows is given in $headers we use the keys from the // first row for the header values if ($rows === null) { $rows = $headers; $keys = array_keys(array_shift($headers)); $headers = array(); foreach ($keys as $header) { $headers[$header] = $header; } } $this->setHeaders($headers); $this->setRows($rows); } if (!empty($footers)) { $this->setFooters($footers); } if ($this->isPiped()) { $this->setRenderer(new Tabular()); } else { $this->setRenderer(new Ascii()); } }
public function __construct($items, $default = null, $title = 'Choose an item') { parent::__construct(); $this->_items = $items; $this->_title = $title; if ($default && strpos($title, '[') === false && isset($items[$default])) { $this->_title .= " [{$items[$default]}]"; } }
public function __construct(Exception $exception) { parent::__construct(); $this->_exception = $exception; /* * Setup style for outputting exception to stderr */ $info = new StyleFormatter('white', 'red'); $this->setFormatter('exception', $info); }
public function __construct($applicationName = '', $version = '', $argv = null) { $this->_start_time = microtime(true); if (!$argv) { $argv = $_SERVER['argv']; } ExceptionHandler::setConsole($this); set_exception_handler('Primer\\Console\\Exception\\ExceptionHandler::handleException'); $this->_applicationName = $applicationName; $this->_version = $version; $this->_userPassedArgv = $argv; $this->_arguments = new Arguments(array('flags' => $this->_flags)); parent::__construct(); }
/** * Instatiates a Notification object. * * @param string $msg The text to display next to the Notifier. * @param int $interval The interval in milliseconds between updates. */ public function __construct($msg, $interval = 100) { parent::__construct(); $this->_message = $msg; $this->_interval = (int) $interval; }