Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-haproff committed May 17, 2016
0 parents commit 0913269
Show file tree
Hide file tree
Showing 17 changed files with 823 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.DS_Store
vendor
19 changes: 19 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "mannum/eventor",
"description": "Simple event-sourcing framework for EventStore.",
"keywords": ["event-sourcing"],

"authors": [
{
"name": "Alex Haproff",
"email": "[email protected]"
}
],
"require": {
"predis/predis": "^1.0",
"guzzlehttp/guzzle": "^6.2"
},
"autoload": {
"psr-4": {"Eventor\\": "src/Eventor"}
}
}
289 changes: 289 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/Eventor/CommandBus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Eventor;


class CommandBus implements CommandBusInterface
{
protected $commandHandlers = [];

public function addCommandHandler($messageName, callable $handler)
{
$this->commandHandlers[$messageName] = $handler;
}

public function handle($message)
{
if (empty($message::$name)) return;

if (empty($this->commandHandlers[$message::$name])) return;

$this->commandHandlers[$message::$name]($message);
}
}
12 changes: 12 additions & 0 deletions src/Eventor/CommandBusInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace Eventor;


interface CommandBusInterface
{
/**
* @param object $message
* @return void
*/
public function handle($message);
}
Loading

0 comments on commit 0913269

Please sign in to comment.