Skip to content

Commit

Permalink
Merge 992b9b0 into d37ad3c
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-rose committed Jun 27, 2019
2 parents d37ad3c + 992b9b0 commit eff347f
Show file tree
Hide file tree
Showing 82 changed files with 949 additions and 431 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 jellyfishphp
Copyright (c) 2018-2019 jellyfishphp

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
4 changes: 1 addition & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
<arg value="xml"/>
<arg value="design,cleancode,codesize"/>
<arg value="--exclude"/>
<arg value="*Test.php"/>
<arg value="--exclude"/>
<arg value="TransferServiceProvider.php"/>
<arg value="EventServiceProvider.php,TransferServiceProvider.php,*Test.php"/>
</exec>
</target>

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"require-dev": {
"codeception/codeception": "~2.4.5",
"mikey179/vfsStream": "~1.6.5",
"mikey179/vfsstream": "~1.6.6",
"php-coveralls/php-coveralls": "~2.1.0",
"phpmd/phpmd": "~2.6.0",
"phpro/grumphp": "~0.14.1",
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ parameters:
whitelist_patterns:
- '/^packages\/[a-z\-]+\/src\/(.*)\.php/'
phpmd:
exclude: ['*Test.php', 'TransferServiceProvider.php']
exclude: ['*Test.php', 'TransferServiceProvider.php', 'EventServiceProvider.php']
ruleset:
- 'cleancode'
- 'codesize'
Expand Down
2 changes: 1 addition & 1 deletion packages/application/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<arg value="xml"/>
<arg value="design,cleancode,codesize"/>
<arg value="--exclude"/>
<arg value="*Test.php"/>
<arg value="EventServiceProvider.php,TransferServiceProvider.php,*Test.php"/>
</exec>
</target>

Expand Down
2 changes: 1 addition & 1 deletion packages/application/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"require-dev": {
"codeception/codeception": "~2.4.5",
"mikey179/vfsStream": "~1.6.5",
"mikey179/vfsstream": "~1.6.6",
"php-coveralls/php-coveralls": "~2.1.0",
"phpmd/phpmd": "~2.6.0",
"phpro/grumphp": "~0.14.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<arg value="xml"/>
<arg value="design,cleancode,codesize"/>
<arg value="--exclude"/>
<arg value="*Test.php"/>
<arg value="EventServiceProvider.php,TransferServiceProvider.php,*Test.php"/>
</exec>
</target>

Expand Down
2 changes: 1 addition & 1 deletion packages/config/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"require-dev": {
"codeception/codeception": "~2.4.5",
"mikey179/vfsStream": "~1.6.5",
"mikey179/vfsstream": "~1.6.6",
"php-coveralls/php-coveralls": "~2.1.0",
"phpmd/phpmd": "~2.6.0",
"phpro/grumphp": "~0.14.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/event/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<arg value="xml"/>
<arg value="design,cleancode,codesize"/>
<arg value="--exclude"/>
<arg value="*Test.php"/>
<arg value="EventServiceProvider.php,TransferServiceProvider.php,*Test.php"/>
</exec>
</target>

Expand Down
2 changes: 1 addition & 1 deletion packages/event/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require-dev": {
"codeception/codeception": "~2.4.5",
"mikey179/vfsStream": "~1.6.5",
"mikey179/vfsstream": "~1.6.6",
"php-coveralls/php-coveralls": "~2.1.0",
"phpmd/phpmd": "~2.6.0",
"phpro/grumphp": "~0.14.1",
Expand Down
65 changes: 65 additions & 0 deletions packages/event/src/Jellyfish/Event/AbstractEventListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Jellyfish\Event;

use Closure;
use Exception;

abstract class AbstractEventListener implements EventListenerInterface
{
/**
* @var \Closure|null
*/
protected $errorHandler;

/**
* @param \Closure|null $errorHandler
*
* @return \Jellyfish\Event\EventListenerInterface
*/
public function setErrorHandler(?Closure $errorHandler): EventListenerInterface
{
$this->errorHandler = $errorHandler;

return $this;
}

/**
* @param \Jellyfish\Event\EventInterface $event
* @return \Jellyfish\Event\EventListenerInterface
*/
public function handle(EventInterface $event): EventListenerInterface
{
try {
$this->doHandle($event);
} catch (Exception $e) {
$this->handleError($e, $event);
}

return $this;
}

/**
* @param \Jellyfish\Event\EventInterface $event
*
* @return \Jellyfish\Event\EventListenerInterface
*/
abstract protected function doHandle(EventInterface $event): EventListenerInterface;

/**
* @param \Exception $e
* @param \Jellyfish\Event\EventInterface $event
*
* @return \Jellyfish\Event\EventListenerInterface
*/
protected function handleError(Exception $e, EventInterface $event): EventListenerInterface
{
if ($this->errorHandler === null) {
return $this;
}

$this->errorHandler->call($this, $e, $event);

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Jellyfish\Event\Command;

use Jellyfish\Event\EventDispatcherInterface;
use Jellyfish\Event\EventListenerProviderInterface;
use Jellyfish\Event\EventListenerInterface;
use Jellyfish\Event\EventQueueConsumerInterface;
use Jellyfish\Lock\LockFactoryInterface;
Expand All @@ -22,7 +22,7 @@ class EventQueueConsumeCommand extends Command
public const DESCRIPTION = 'Consume from event queue';

/**
* @param \Jellyfish\Event\EventDispatcherInterface $eventDispatcher
* @param \Jellyfish\Event\EventListenerProviderInterface $eventDispatcher
*/
protected $eventDispatcher;

Expand All @@ -37,13 +37,13 @@ class EventQueueConsumeCommand extends Command
protected $logger;

/**
* @param \Jellyfish\Event\EventDispatcherInterface $eventDispatcher
* @param \Jellyfish\Event\EventListenerProviderInterface $eventDispatcher
* @param \Jellyfish\Event\EventQueueConsumerInterface $eventQueueConsumer
* @param \Jellyfish\Lock\LockFactoryInterface $lockFactory
* @param \Psr\Log\LoggerInterface $logger
*/
public function __construct(
EventDispatcherInterface $eventDispatcher,
EventListenerProviderInterface $eventDispatcher,
EventQueueConsumerInterface $eventQueueConsumer,
LockFactoryInterface $lockFactory,
LoggerInterface $logger
Expand Down
25 changes: 25 additions & 0 deletions packages/event/src/Jellyfish/Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class Event implements EventInterface
*/
protected $name;

/**
* @var int
*/
protected $retries;

/**
* @var object
*/
Expand All @@ -34,6 +39,26 @@ public function setName(string $name): EventInterface
return $this;
}

/**
* @return int
*/
public function getRetries(): int
{
return $this->retries;
}

/**
* @param int $retries
*
* @return \Jellyfish\Event\EventInterface
*/
public function setRetries(int $retries): EventInterface
{
$this->retries = $retries;

return $this;
}

/**
* @return object
*/
Expand Down

0 comments on commit eff347f

Please sign in to comment.