4 use Robo\Contract\OutputAdapterInterface;
5 use Robo\Contract\OutputAwareInterface;
6 use Robo\Contract\VerbosityThresholdInterface;
7 use Symfony\Component\Console\Output\OutputInterface;
10 * Adapt OutputInterface or other output function to the VerbosityThresholdInterface.
12 class OutputAdapter implements OutputAdapterInterface, OutputAwareInterface
16 protected $verbosityMap = [
17 VerbosityThresholdInterface::VERBOSITY_NORMAL => OutputInterface::VERBOSITY_NORMAL,
18 VerbosityThresholdInterface::VERBOSITY_VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
19 VerbosityThresholdInterface::VERBOSITY_VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
20 VerbosityThresholdInterface::VERBOSITY_DEBUG => OutputInterface::VERBOSITY_DEBUG,
23 public function verbosityMeetsThreshold($verbosityThreshold)
25 if (!isset($this->verbosityMap[$verbosityThreshold])) {
28 $verbosityThreshold = $this->verbosityMap[$verbosityThreshold];
29 $verbosity = $this->output()->getVerbosity();
31 return $verbosity >= $verbosityThreshold;
34 public function writeMessage($message)
36 $this->output()->write($message);