/** * @inheritdoc */ public function flush() { $data = $this->get(self::CONTENT); if (is_array($data) or is_object($data)) { $this->set(self::CONTENT, json_encode($data)); } parent::flush(); }
/** * @inheritdoc */ public function flush() { $data = $this->get(self::CONTENT); if (!is_scalar($data)) { $this->set(self::CONTENT, print_r($data, true)); } parent::flush(); }
/** * @inheritdoc */ public function flush() { if ($this->output_config->get('add_timestamp_to_static_link')) { $t = $this; $content = $this->get(self::CONTENT); $ext_pattern = implode('|', $this->output_config->get('static_file_ext')); $get_mtime_callback = $this->output_config->get('get_mtime_callback'); $add_timestamp_callback = $this->output_config->get('add_timestamp_callback'); $pattern = '@(?<=\\<[^>]+\\s+(href|src)\\s*=\\s*["\']?)([^\'"]+)(?=["\' ])@is'; $content = preg_replace_callback($pattern, function ($match) use($t, $ext_pattern, $get_mtime_callback, $add_timestamp_callback) { if (preg_match("@\\.({$ext_pattern})@is", $match[1])) { $timestamp = call_user_func($get_mtime_callback, $match[1]); return call_user_func($add_timestamp_callback, $match[1], $timestamp); } else { return $match[1]; } }, $content); $this->set(self::CONTENT, $content); } parent::flush(); }
/** * @param string $string * @param string $type * @throws \JakubOnderka\PhpConsoleColor\InvalidStyleException */ public function write($string, $type = self::TYPE_DEFAULT) { if (!$this->colors instanceof \JakubOnderka\PhpConsoleColor\ConsoleColor) { parent::write($string, $type); } else { switch ($type) { case self::TYPE_OK: parent::write($this->colors->apply('bg_green', $string)); break; case self::TYPE_SKIP: parent::write($this->colors->apply('bg_yellow', $string)); break; case self::TYPE_ERROR: parent::write($this->colors->apply('bg_red', $string)); break; default: parent::write($string); } } }