Skip to content

Commit

Permalink
Code formatting & standards fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnicholson committed Jan 25, 2015
1 parent f93045c commit c5bd8f1
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Bridge/Laravel/IlluminateEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

class IlluminateEventDispatcher implements EventDispatcher
{
protected $dispatcher;

/**
* @param Dispatcher $dispatcher
*/
public function __construct(Dispatcher $dispatcher)
{
$this->dispatcher = $dispatcher;
Expand Down
7 changes: 7 additions & 0 deletions src/Bridge/Laravel/IlluminateQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class IlluminateQueueHandler
{
protected $bus;

/**
* @param SynchronousCommandBus $bus
*/
public function __construct(SynchronousCommandBus $bus)
{
$this->bus = $bus;
Expand All @@ -16,5 +21,7 @@ public function fire($job, $serializedCommand)
$command = unserialize($serializedCommand);

$this->bus->execute($command);

$job->delete();
}
}
14 changes: 14 additions & 0 deletions src/Busses/QueueingCommandBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@
*/
class QueueingCommandBus implements CommandBus
{
/**
* @var \Chief\CommandBus
*/
protected $innerBus;

/**
* @var \Chief\CommandBusQueuer
*/
protected $queuer;

/**
* @param CommandBusQueuer $queuer
* @param CommandBus $innerBus
*/
public function __construct(CommandBusQueuer $queuer, CommandBus $innerBus = null)
{
$this->queuer = $queuer;
Expand Down
14 changes: 14 additions & 0 deletions src/Busses/TransactionalCommandBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,23 @@
*/
class TransactionalCommandBus implements CommandBus
{
/**
* Whether or not a Command is in progress and the bus is locked
* @var bool
*/
protected $locked = false;

/**
* Queued Commands to be executed when the current command finishes
* @var array
*/
protected $queue = [];

/**
* @var CommandBus
*/
protected $innerBus;

public function __construct(CommandBus $innerBus = null)
{
$this->innerBus = $innerBus ?: new SynchronousCommandBus();
Expand Down
5 changes: 5 additions & 0 deletions src/Chief.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
*/
class Chief implements CommandBus
{
/**
* @var CommandBus
*/
protected $bus;

/**
* Constructor
*
Expand Down
19 changes: 19 additions & 0 deletions src/Decorators/EventDispatchingDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,23 @@
use Chief\Command;
use Chief\CommandBus;
use Chief\Decorator;
use Exception;

class EventDispatchingDecorator implements Decorator
{
/**
* @var EventDispatcher
*/
protected $dispatcher;

/**
* @var CommandBus
*/
protected $innerCommandBus;

/**
* @param EventDispatcher $dispatcher
*/
public function __construct(EventDispatcher $dispatcher)
{
$this->dispatcher = $dispatcher;
Expand All @@ -23,9 +37,14 @@ public function setInnerBus(CommandBus $bus)
*
* @param Command $command
* @return mixed
* @throws \Exception
*/
public function execute(Command $command)
{
if (!$this->innerCommandBus) {
throw new Exception('No inner bus defined for this decorator. Set an inner bus with setInnerBus()');
}

$response = $this->innerCommandBus->execute($command);

$eventName = $this->getEventName($command);
Expand Down
6 changes: 5 additions & 1 deletion src/Handlers/LazyLoadingCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ class LazyLoadingCommandHandler implements CommandHandler
protected $container;

/**
* @var \Chief\CommandHandler
* @var string
*/
protected $handler;

/**
* @param string $handlerName
* @param Container $container
*/
public function __construct($handlerName, Container $container)
{
$this->container = $container;
Expand Down

0 comments on commit c5bd8f1

Please sign in to comment.