[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Application/CLI/ -> CliOutput.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Application\CLI;
  11  
  12  use Joomla\CMS\Application\CLI\Output\Processor\ProcessorInterface;
  13  
  14  // phpcs:disable PSR1.Files.SideEffects
  15  \defined('JPATH_PLATFORM') or die;
  16  // phpcs:enable PSR1.Files.SideEffects
  17  
  18  /**
  19   * Base class defining a command line output handler
  20   *
  21   * @since       4.0.0
  22   * @deprecated  5.0  Use the `joomla/console` package instead
  23   */
  24  abstract class CliOutput
  25  {
  26      /**
  27       * Output processing object
  28       *
  29       * @var    ProcessorInterface
  30       * @since  4.0.0
  31       */
  32      protected $processor;
  33  
  34      /**
  35       * Constructor
  36       *
  37       * @param   ProcessorInterface  $processor  The output processor.
  38       *
  39       * @since   4.0.0
  40       */
  41      public function __construct(ProcessorInterface $processor = null)
  42      {
  43          $this->setProcessor($processor ?: new Output\Processor\ColorProcessor());
  44      }
  45  
  46      /**
  47       * Set a processor
  48       *
  49       * @param   ProcessorInterface  $processor  The output processor.
  50       *
  51       * @return  $this
  52       *
  53       * @since   4.0.0
  54       */
  55      public function setProcessor(ProcessorInterface $processor)
  56      {
  57          $this->processor = $processor;
  58  
  59          return $this;
  60      }
  61  
  62      /**
  63       * Get a processor
  64       *
  65       * @return  ProcessorInterface
  66       *
  67       * @since   4.0.0
  68       * @throws  \RuntimeException
  69       */
  70      public function getProcessor()
  71      {
  72          if ($this->processor) {
  73              return $this->processor;
  74          }
  75  
  76          throw new \RuntimeException('A ProcessorInterface object has not been set.');
  77      }
  78  
  79      /**
  80       * Write a string to an output handler.
  81       *
  82       * @param   string   $text  The text to display.
  83       * @param   boolean  $nl    True (default) to append a new line at the end of the output string.
  84       *
  85       * @return  $this
  86       *
  87       * @since   4.0.0
  88       * @codeCoverageIgnore
  89       */
  90      abstract public function out($text = '', $nl = true);
  91  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer