b8e795f23cb48d1d449ba547383b1199fcf05317
[yaffs-website] / vendor / consolidation / robo / src / Common / OutputAdapter.php
1 <?php
2 namespace Robo\Common;
3
4 use Robo\Contract\OutputAdapterInterface;
5 use Robo\Contract\OutputAwareInterface;
6 use Robo\Contract\VerbosityThresholdInterface;
7 use Symfony\Component\Console\Output\OutputInterface;
8
9 /**
10  * Adapt OutputInterface or other output function to the VerbosityThresholdInterface.
11  */
12 class OutputAdapter implements OutputAdapterInterface, OutputAwareInterface
13 {
14     use OutputAwareTrait;
15
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,
21     ];
22
23     public function verbosityMeetsThreshold($verbosityThreshold)
24     {
25         if (!isset($this->verbosityMap[$verbosityThreshold])) {
26             return true;
27         }
28         $verbosityThreshold = $this->verbosityMap[$verbosityThreshold];
29         $verbosity = $this->output()->getVerbosity();
30
31         return $verbosity >= $verbosityThreshold;
32     }
33
34     public function writeMessage($message)
35     {
36         $this->output()->write($message);
37     }
38 }