Created
July 10, 2017 08:30
-
-
Save ScullWM/7e5302be6e282afe5611f7429266525c to your computer and use it in GitHub Desktop.
Mock Asynch bus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Xeonys\Tests\Features\Mock; | |
use Rezzza\CommandBus\Domain\CommandBusInterface; | |
use Rezzza\CommandBus\Domain\CommandInterface; | |
class CommandBusMock implements CommandBusInterface | |
{ | |
const FILENAME = 'async_queue'; | |
private $cmd = array(); | |
public function getHandleType() | |
{ | |
return; | |
} | |
public function handle(CommandInterface $command, $priority = null) | |
{ | |
$this->cmd[] = $this->dumpCmd($command); | |
file_put_contents(__DIR__.'/../../../../web/'.self::FILENAME . '.json', json_encode(['items' => $this->cmd])); | |
} | |
private function dumpCmd(CommandInterface $command) | |
{ | |
$className = get_class($command); | |
$user = $command->getUser(); | |
$connection = $command->getConnection(); | |
return [ | |
'className' => $className, | |
'user' => $user, | |
'connection' => $connection, | |
'channel' => $command->getChannel()->getName(), | |
'cmd' => $command, | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment