Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Common / CommandReceiver.php
1 <?php
2 namespace Robo\Common;
3
4 use Robo\Contract\CommandInterface;
5 use Robo\Exception\TaskException;
6
7 /**
8  * This task can receive commands from task implementing CommandInterface.
9  */
10 trait CommandReceiver
11 {
12     /**
13      * @param string|\Robo\Contract\CommandInterface $command
14      *
15      * @return string
16      *
17      * @throws \Robo\Exception\TaskException
18      */
19     protected function receiveCommand($command)
20     {
21         if (!is_object($command)) {
22             return $command;
23         }
24         if ($command instanceof CommandInterface) {
25             return $command->getCommand();
26         } else {
27             throw new TaskException($this, get_class($command) . " does not implement CommandInterface, so can't be passed into this task");
28         }
29     }
30 }