Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Common / OutputAdapter.php
diff --git a/vendor/consolidation/robo/src/Common/OutputAdapter.php b/vendor/consolidation/robo/src/Common/OutputAdapter.php
new file mode 100644 (file)
index 0000000..b8e795f
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+namespace Robo\Common;
+
+use Robo\Contract\OutputAdapterInterface;
+use Robo\Contract\OutputAwareInterface;
+use Robo\Contract\VerbosityThresholdInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Adapt OutputInterface or other output function to the VerbosityThresholdInterface.
+ */
+class OutputAdapter implements OutputAdapterInterface, OutputAwareInterface
+{
+    use OutputAwareTrait;
+
+    protected $verbosityMap = [
+        VerbosityThresholdInterface::VERBOSITY_NORMAL => OutputInterface::VERBOSITY_NORMAL,
+        VerbosityThresholdInterface::VERBOSITY_VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
+        VerbosityThresholdInterface::VERBOSITY_VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
+        VerbosityThresholdInterface::VERBOSITY_DEBUG => OutputInterface::VERBOSITY_DEBUG,
+    ];
+
+    public function verbosityMeetsThreshold($verbosityThreshold)
+    {
+        if (!isset($this->verbosityMap[$verbosityThreshold])) {
+            return true;
+        }
+        $verbosityThreshold = $this->verbosityMap[$verbosityThreshold];
+        $verbosity = $this->output()->getVerbosity();
+
+        return $verbosity >= $verbosityThreshold;
+    }
+
+    public function writeMessage($message)
+    {
+        $this->output()->write($message);
+    }
+}