-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Jeckel-Lab/feature/query-bus
Add interfaces for a Query Bus
- Loading branch information
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/Core/QueryDispatcher/Exception/InvalidQueryException.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @author: Julien Mercier-Rojas <julien@jeckel-lab.fr> | ||
* Created at: 08/11/2021 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JeckelLab\Contract\Core\QueryDispatcher\Exception; | ||
|
||
use JeckelLab\Contract\Core\Exception\RuntimeException; | ||
|
||
/** | ||
* Class InvalidQueryException | ||
* @package JeckelLab\Contract\Core\QueryDispatcher\Exception | ||
* @psalm-immutable | ||
*/ | ||
class InvalidQueryException extends RuntimeException implements QueryDispatcherException | ||
{ | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/Core/QueryDispatcher/Exception/QueryDispatcherException.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* @author: Julien Mercier-Rojas <julien@jeckel-lab.fr> | ||
* Created at: 08/11/2021 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JeckelLab\Contract\Core\QueryDispatcher\Exception; | ||
|
||
use JeckelLab\Contract\Core\Exception\CoreException; | ||
|
||
/** | ||
* @psalm-immutable | ||
*/ | ||
interface QueryDispatcherException extends CoreException | ||
{ | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* @author: Julien Mercier-Rojas <julien@jeckel-lab.fr> | ||
* Created at: 08/11/2021 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JeckelLab\Contract\Core\QueryDispatcher\Query; | ||
|
||
/** | ||
* @psalm-immutable | ||
*/ | ||
interface Query | ||
{ | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* @author: Julien Mercier-Rojas <julien@jeckel-lab.fr> | ||
* Created at: 08/11/2021 | ||
*/ | ||
|
||
namespace JeckelLab\Contract\Core\QueryDispatcher\QueryBus; | ||
|
||
use JeckelLab\Contract\Core\QueryDispatcher\Query\Query; | ||
use JeckelLab\Contract\Presentation\ViewModel\ViewModel; | ||
|
||
interface QueryBus | ||
{ | ||
/** | ||
* @param Query $query | ||
* @return ViewModel | ||
*/ | ||
public function dispatch(Query $query): ViewModel; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/** | ||
* @author: Julien Mercier-Rojas <julien@jeckel-lab.fr> | ||
* Created at: 08/11/2021 | ||
*/ | ||
|
||
namespace JeckelLab\Contract\Core\QueryDispatcher\QueryHandler; | ||
|
||
use JeckelLab\Contract\Core\QueryDispatcher\Exception\InvalidQueryException; | ||
use JeckelLab\Contract\Core\QueryDispatcher\Query\Query; | ||
use JeckelLab\Contract\Presentation\ViewModel\ViewModel; | ||
|
||
interface QueryHandler | ||
{ | ||
/** | ||
* @return array<class-string<Query>> | ||
* @psalm-mutation-free | ||
*/ | ||
public static function getHandledQueries(): array; | ||
|
||
/** | ||
* @param Query $query | ||
* @return ViewModel | ||
* @throws InvalidQueryException | ||
*/ | ||
public function __invoke(Query $query): ViewModel; | ||
} |