Example #1
0
 /**
  * Executes the given command and optionally returns a value
  *
  * @param object $command
  *
  * @return mixed
  */
 public function handle($command)
 {
     if (!is_object($command)) {
         throw InvalidCommandException::forUnknownValue($command);
     }
     $middlewareChain = $this->middlewareChain;
     return $middlewareChain($command);
 }
 public function testExceptionContainsDebuggingInfo()
 {
     $command = 'must be an object';
     $exception = InvalidCommandException::forUnknownValue($command);
     $this->assertContains('type: string', $exception->getMessage());
     $this->assertSame($command, $exception->getInvalidCommand());
     $this->assertInstanceOf(Exception::class, $exception);
 }
 /**
  * @inheritDoc
  */
 public function handle($command)
 {
     if (!is_object($command)) {
         throw InvalidCommandException::forUnknownValue($command);
     }
     $this->checkTransactionIsRunning();
     $this->commandsToCommit[] = $command;
     return true;
 }