Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Common / CommandReceiver.php
diff --git a/vendor/consolidation/robo/src/Common/CommandReceiver.php b/vendor/consolidation/robo/src/Common/CommandReceiver.php
new file mode 100644 (file)
index 0000000..03b20fc
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace Robo\Common;
+
+use Robo\Contract\CommandInterface;
+use Robo\Exception\TaskException;
+
+/**
+ * This task can receive commands from task implementing CommandInterface.
+ */
+trait CommandReceiver
+{
+    /**
+     * @param string|\Robo\Contract\CommandInterface $command
+     *
+     * @return string
+     *
+     * @throws \Robo\Exception\TaskException
+     */
+    protected function receiveCommand($command)
+    {
+        if (!is_object($command)) {
+            return $command;
+        }
+        if ($command instanceof CommandInterface) {
+            return $command->getCommand();
+        } else {
+            throw new TaskException($this, get_class($command) . " does not implement CommandInterface, so can't be passed into this task");
+        }
+    }
+}