Skip to content

Commit

Permalink
Merge pull request #28 from Jeckel-Lab/feature/predefined-responses
Browse files Browse the repository at this point in the history
Feature/predefined responses
  • Loading branch information
jeckel authored Mar 9, 2021
2 parents a94d06f + bd1ffc0 commit 6d36796
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: validate

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
global-qa-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: 7.4
- name: Get composer cache directory
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-7.4-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-7.4
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --dev
- name: php MD
run: ./vendor/bin/phpmd src text ./ruleset.xml
- name: php CD
run: ./vendor/bin/phpcs
- name: PHPUnit Coverage
run: ./vendor/bin/phpunit --coverage-clover coverage.xml
- uses: codecov/codecov-action@v1

psalm-over-php-versions:
strategy:
fail-fast: false
matrix:
php-versions: [ '7.2', '7.3', '7.4', '8.0' ]
include:
- php-versions: 7.2
env: COMPOSER_FLAGS="--prefer-lowest"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
- name: Get composer cache directory
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-versions }}
- name: Install dependencies
run: composer install $COMPOSER_FLAGS --no-interaction --prefer-dist --dev
- name: Psalm
run: ./vendor/bin/psalm
30 changes: 30 additions & 0 deletions src/CommandHandler/InvalidCommandProvidedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @author: Julien Mercier-Rojas <[email protected]>
* Created at: 09/03/2021
*/
declare(strict_types=1);

namespace JeckelLab\CommandDispatcher\CommandHandler;

use JeckelLab\Contract\Core\CommandDispatcher\Exception\InvalidCommandException;

/**
* Class InvalidCommandProvidedException
* @package JeckelLab\CommandDispatcher\CommandHandler
* @psalm-immutable
*/
class InvalidCommandProvidedException extends InvalidCommandException
{
public function __construct(string $expectedCommandFqcn, string $providedCommandFqcn)
{
parent::__construct(
sprintf(
'Invalid command provided, expected %s, but got %s.',
$expectedCommandFqcn,
$providedCommandFqcn
)
);
}
}
33 changes: 33 additions & 0 deletions src/CommandResponse/CommandResponseFailure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @author: Julien Mercier-Rojas <[email protected]>
* Created at: 09/03/2021
*/
declare(strict_types=1);

namespace JeckelLab\CommandDispatcher\CommandResponse;

use JeckelLab\Contract\Core\CommandDispatcher\CommandResponse\CommandResponse as CommandResponseInterface;
use JeckelLab\Contract\Domain\Event\Event;

/**
* Class CommandResponseFailure
* @package JeckelLab\CommandDispatcher\CommandResponse
* @psalm-immutable
*/
class CommandResponseFailure implements CommandResponseInterface
{
use CommandResponseAckTrait;
use CommandResponseEventsTrait;

/**
* CommandResponseAbstract constructor.
* @param iterable<Event>|null $events
*/
public function __construct(?iterable $events = null)
{
$this->ack = false;
$this->events = $events;
}
}
33 changes: 33 additions & 0 deletions src/CommandResponse/CommandResponseSuccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @author: Julien Mercier-Rojas <[email protected]>
* Created at: 09/03/2021
*/
declare(strict_types=1);

namespace JeckelLab\CommandDispatcher\CommandResponse;

use JeckelLab\Contract\Core\CommandDispatcher\CommandResponse\CommandResponse as CommandResponseInterface;
use JeckelLab\Contract\Domain\Event\Event;

/**
* Class CommandResponseSuccess
* @package JeckelLab\CommandDispatcher\CommandResponse
* @psalm-immutable
*/
class CommandResponseSuccess implements CommandResponseInterface
{
use CommandResponseAckTrait;
use CommandResponseEventsTrait;

/**
* CommandResponseAbstract constructor.
* @param iterable<Event>|null $events
*/
public function __construct(?iterable $events = null)
{
$this->ack = true;
$this->events = $events;
}
}

0 comments on commit 6d36796

Please sign in to comment.