From 26d4ca787f92da47f5cf7d31eb19baf1d9fa0bc1 Mon Sep 17 00:00:00 2001 From: KHOUBZA Younes Date: Thu, 3 Dec 2020 09:15:47 +0100 Subject: [PATCH] update namespace --- Dispatcher/Event/AfterFilter.php | 8 +++ .../Event/AfterNotificationDispatched.php | 8 +++ .../Event/AfterNotificationRendered.php | 8 +++ Dispatcher/Event/BeforeFilter.php | 8 +++ .../Event/BeforeNotificationDispatched.php | 8 +++ .../Event/BeforeNotificationRendered.php | 8 +++ Dispatcher/Event/EventInterface.php | 8 +++ Dispatcher/Event/NotificationDispatched.php | 8 +++ Dispatcher/Event/NotificationRendered.php | 8 +++ Dispatcher/Event/PresenterReady.php | 8 +++ Dispatcher/EventDispatcher.php | 58 +++++++++++++++++++ Dispatcher/EventDispatcherInterface.php | 23 ++++++++ Dispatcher/FlusherEvents.php | 12 ++++ Dispatcher/Listener/ListenerInterface.php | 10 ++++ Dispatcher/Listener/SubscriberInterface.php | 8 +++ Envelope.php | 6 +- .../AbstractFlasher.php | 12 ++-- Factory/FactoryInterface.php | 27 +++++++++ Filter/CriteriaBuilder.php | 10 ++-- Filter/DefaultFilter.php | 2 +- Filter/FilterBuilder.php | 32 ++++++---- Filter/FilterInterface.php | 2 +- Filter/FilterManager.php | 6 +- Filter/Specification/AndSpecification.php | 6 +- Filter/Specification/NotSpecification.php | 6 +- Filter/Specification/OrSpecification.php | 6 +- .../Specification/PrioritySpecification.php | 8 +-- ...cification.php => ReplaySpecification.php} | 14 ++--- .../Specification/SpecificationInterface.php | 6 +- Filter/Specification/TimeSpecification.php | 8 +-- Flasher.php | 6 +- Manager/AbstractManager.php | 4 +- Middleware/AddCreatedAtStampMiddleware.php | 8 +-- Middleware/AddHopsStampMiddleware.php | 18 ++++++ Middleware/AddPriorityStampMiddleware.php | 8 +-- Middleware/AddRenderedAtStampMiddleware.php | 8 +-- Middleware/AddReplayStampMiddleware.php | 18 ------ Middleware/MiddlewareInterface.php | 8 +-- Middleware/NotifyBus.php | 13 +++-- Notification/Notification.php | 2 +- Notification/NotificationBuilder.php | 21 ++++++- Notification/NotificationBuilderInterface.php | 12 ++-- Notification/NotificationInterface.php | 2 +- Presenter/AbstractPresenter.php | 47 ++++++++------- Presenter/Adapter/HtmlPresenter.php | 12 ++-- Presenter/Adapter/JsonPresenter.php | 8 +-- Presenter/PresenterInterface.php | 2 +- Presenter/PresenterManager.php | 6 +- Renderer/HasOptionsInterface.php | 2 +- Renderer/HasScriptsInterface.php | 2 +- Renderer/HasStylesInterface.php | 2 +- Renderer/RendererInterface.php | 6 +- Renderer/RendererManager.php | 6 +- Stamp/CreatedAtStamp.php | 20 ++++--- Stamp/HandlerStamp.php | 2 +- Stamp/{ReplayStamp.php => HopsStamp.php} | 4 +- Stamp/OrderableStampInterface.php | 4 +- Stamp/PriorityStamp.php | 4 +- Stamp/RenderedAtStamp.php | 18 +++--- Stamp/StampInterface.php | 2 +- Stamp/UuidStamp.php | 10 ++-- Storage/ArrayStorage.php | 12 ++-- Storage/StorageInterface.php | 10 ++-- Storage/StorageManager.php | 14 ++--- Storage/StorageManagerInterface.php | 12 ++-- Tests/Envelope/EnvelopeTest.php | 36 ++++++------ Tests/Envelope/Stamp/CreatedAtStampTest.php | 18 +++--- Tests/Envelope/Stamp/LifeStampTest.php | 10 ++-- Tests/Envelope/Stamp/PriorityStampTest.php | 14 ++--- Tests/Envelope/Stamp/RendererStampTest.php | 10 ++-- Tests/Envelope/Stamp/UuidStampTest.php | 10 ++-- Tests/Filter/CriteriaBuilderTest.php | 16 ++--- Tests/Filter/DefaultFilterTest.php | 20 +++---- Tests/Filter/FilterManagerTest.php | 32 +++++----- Tests/Manager/ManagerTest.php | 6 +- Tests/Notification/NotificationTest.php | 2 +- Tests/Producer/ProducerManagerTest.php | 12 ++-- Tests/Storage/ArrayStorageTest.php | 10 ++-- Tests/Storage/StorageManagerTest.php | 16 ++--- Translator/TranslatorInterface.php | 8 +++ 80 files changed, 582 insertions(+), 313 deletions(-) create mode 100644 Dispatcher/Event/AfterFilter.php create mode 100644 Dispatcher/Event/AfterNotificationDispatched.php create mode 100644 Dispatcher/Event/AfterNotificationRendered.php create mode 100644 Dispatcher/Event/BeforeFilter.php create mode 100644 Dispatcher/Event/BeforeNotificationDispatched.php create mode 100644 Dispatcher/Event/BeforeNotificationRendered.php create mode 100644 Dispatcher/Event/EventInterface.php create mode 100644 Dispatcher/Event/NotificationDispatched.php create mode 100644 Dispatcher/Event/NotificationRendered.php create mode 100644 Dispatcher/Event/PresenterReady.php create mode 100644 Dispatcher/EventDispatcher.php create mode 100644 Dispatcher/EventDispatcherInterface.php create mode 100644 Dispatcher/FlusherEvents.php create mode 100644 Dispatcher/Listener/ListenerInterface.php create mode 100644 Dispatcher/Listener/SubscriberInterface.php rename AbstractFlasher.php => Factory/AbstractFlasher.php (82%) create mode 100644 Factory/FactoryInterface.php rename Filter/Specification/{LifeSpecification.php => ReplaySpecification.php} (56%) create mode 100644 Middleware/AddHopsStampMiddleware.php delete mode 100644 Middleware/AddReplayStampMiddleware.php rename Stamp/{ReplayStamp.php => HopsStamp.php} (77%) create mode 100644 Translator/TranslatorInterface.php diff --git a/Dispatcher/Event/AfterFilter.php b/Dispatcher/Event/AfterFilter.php new file mode 100644 index 00000000..90d36ac5 --- /dev/null +++ b/Dispatcher/Event/AfterFilter.php @@ -0,0 +1,8 @@ +listeners[$eventName][] = $listener; + } + + /** + * @inheritDoc + */ + public function dispatch(EventInterface $event, $eventName = null) + { + $eventName = $eventName ?: get_class($event); + + $listeners = $this->getListeners($eventName); + + $this->callListeners($listeners, $event); + + return $event; + } + + /** + * @param string $eventName + * + * @return ListenerInterface[] + */ + public function getListeners($eventName) + { + if (empty($this->listeners[$eventName])) { + return array(); + } + + return $this->listeners[$eventName]; + } + + /** + * @param ListenerInterface[] $listeners + * @param EventInterface $event + */ + protected function callListeners(array $listeners, $event) + { + foreach ($listeners as $listener) { + $listener->handle($event); + } + } +} diff --git a/Dispatcher/EventDispatcherInterface.php b/Dispatcher/EventDispatcherInterface.php new file mode 100644 index 00000000..be9a45af --- /dev/null +++ b/Dispatcher/EventDispatcherInterface.php @@ -0,0 +1,23 @@ +filterBuilder->andWhere(new LifeSpecification($min, $max)); + $this->filterBuilder->andWhere(new ReplaySpecification($min, $max)); } public function buildLimit() diff --git a/Filter/DefaultFilter.php b/Filter/DefaultFilter.php index b72d3416..2f8a49c9 100644 --- a/Filter/DefaultFilter.php +++ b/Filter/DefaultFilter.php @@ -1,6 +1,6 @@ get('Flasher\Prime\TestsStamp\PriorityStamp'); + $stamp = $envelope->get('Flasher\Prime\Stamp\PriorityStamp'); if (null === $stamp) { return false; diff --git a/Filter/Specification/LifeSpecification.php b/Filter/Specification/ReplaySpecification.php similarity index 56% rename from Filter/Specification/LifeSpecification.php rename to Filter/Specification/ReplaySpecification.php index 76791f6b..9253593e 100644 --- a/Filter/Specification/LifeSpecification.php +++ b/Filter/Specification/ReplaySpecification.php @@ -1,10 +1,10 @@ get('Flasher\Prime\TestsStamp\ReplayStamp'); + $stamp = $envelope->get('Flasher\Prime\Stamp\HopsStamp'); if (null === $stamp) { return false; } - if (null !== $this->maxLife && $stamp->getLife() > $this->maxLife) { + if (null !== $this->maxLife && $stamp->getCount() > $this->maxLife) { return false; } - return $stamp->getLife() >= $this->minLife; + return $stamp->getCount() >= $this->minLife; } } diff --git a/Filter/Specification/SpecificationInterface.php b/Filter/Specification/SpecificationInterface.php index fccee585..4d8f6da1 100644 --- a/Filter/Specification/SpecificationInterface.php +++ b/Filter/Specification/SpecificationInterface.php @@ -1,13 +1,13 @@ get('Flasher\Prime\TestsStamp\CreatedAtStamp'); + $stamp = $envelope->get('Flasher\Prime\Stamp\CreatedAtStamp'); if (null === $stamp) { return false; diff --git a/Flasher.php b/Flasher.php index e8d5b333..a48e28df 100644 --- a/Flasher.php +++ b/Flasher.php @@ -2,9 +2,9 @@ namespace Flasher\Prime; -use Flasher\Prime\Config\ConfigInterface; -use Flasher\Prime\TestsNotification\NotificationBuilderInterface; -use Flasher\Prime\TestsNotification\NotificationInterface; +use Flasher\Prime\Manager\AbstractManager; +use Flasher\Prime\Notification\NotificationBuilderInterface; +use Flasher\Prime\Notification\NotificationInterface; /** * @method NotificationBuilderInterface type($type, $message = null, array $options = array()) diff --git a/Manager/AbstractManager.php b/Manager/AbstractManager.php index 0d2e8101..76da596c 100644 --- a/Manager/AbstractManager.php +++ b/Manager/AbstractManager.php @@ -1,9 +1,9 @@ get('Flasher\Prime\TestsStamp\CreatedAtStamp')) { + if (null === $envelope->get('Flasher\Prime\Stamp\CreatedAtStamp')) { $envelope->withStamp(new CreatedAtStamp()); } diff --git a/Middleware/AddHopsStampMiddleware.php b/Middleware/AddHopsStampMiddleware.php new file mode 100644 index 00000000..205e1a9d --- /dev/null +++ b/Middleware/AddHopsStampMiddleware.php @@ -0,0 +1,18 @@ +get('Flasher\Prime\Stamp\HopsStamp')) { + $envelope->withStamp(new HopsStamp(1)); + } + + return $next($envelope); + } +} diff --git a/Middleware/AddPriorityStampMiddleware.php b/Middleware/AddPriorityStampMiddleware.php index e887dd3e..979cb8f0 100644 --- a/Middleware/AddPriorityStampMiddleware.php +++ b/Middleware/AddPriorityStampMiddleware.php @@ -1,15 +1,15 @@ get('Flasher\Prime\TestsStamp\PriorityStamp')) { + if (null === $envelope->get('Flasher\Prime\Stamp\PriorityStamp')) { $envelope->withStamp(new PriorityStamp(0)); } diff --git a/Middleware/AddRenderedAtStampMiddleware.php b/Middleware/AddRenderedAtStampMiddleware.php index f5370673..a6c4db08 100644 --- a/Middleware/AddRenderedAtStampMiddleware.php +++ b/Middleware/AddRenderedAtStampMiddleware.php @@ -1,15 +1,15 @@ get('Flasher\Prime\TestsStamp\RenderedAtStamp')) { + if (null === $envelope->get('Flasher\Prime\Stamp\RenderedAtStamp')) { $envelope->withStamp(new RenderedAtStamp()); } diff --git a/Middleware/AddReplayStampMiddleware.php b/Middleware/AddReplayStampMiddleware.php deleted file mode 100644 index f7433f18..00000000 --- a/Middleware/AddReplayStampMiddleware.php +++ /dev/null @@ -1,18 +0,0 @@ -get('Flasher\Prime\TestsStamp\ReplayStamp')) { - $envelope->withStamp(new ReplayStamp(1)); - } - - return $next($envelope); - } -} diff --git a/Middleware/MiddlewareInterface.php b/Middleware/MiddlewareInterface.php index 40050678..db806fb3 100644 --- a/Middleware/MiddlewareInterface.php +++ b/Middleware/MiddlewareInterface.php @@ -1,16 +1,16 @@ type(NotificationInterface::TYPE_WARNING, $message, $options); } + + public function priority($priority) + { + + } + + public function hops() + { + + } + + public function sticky() + { + + } } diff --git a/Notification/NotificationBuilderInterface.php b/Notification/NotificationBuilderInterface.php index 95e9a993..23cf5a96 100644 --- a/Notification/NotificationBuilderInterface.php +++ b/Notification/NotificationBuilderInterface.php @@ -1,6 +1,6 @@ $options * @param bool $merge * - * @return \Flasher\Prime\TestsNotification\NotificationBuilder + * @return NotificationBuilder */ public function options($options, $merge = true); @@ -32,12 +32,12 @@ interface NotificationBuilderInterface * @param string $name * @param mixed $value * - * @return \Flasher\Prime\TestsNotification\NotificationBuilder + * @return NotificationBuilder */ public function option($name, $value); /** - * @return \Flasher\Prime\TestsNotification\NotificationInterface + * @return NotificationInterface */ public function getNotification(); diff --git a/Notification/NotificationInterface.php b/Notification/NotificationInterface.php index 4ffbbe8e..6c154695 100644 --- a/Notification/NotificationInterface.php +++ b/Notification/NotificationInterface.php @@ -1,6 +1,6 @@ get('Flasher\Prime\TestsStamp\ReplayStamp'); + $lifeStamp = $envelope->get('Flasher\Prime\Stamp\HopsStamp'); return $lifeStamp->getLife() > 0; } @@ -87,7 +87,7 @@ abstract class AbstractPresenter implements PresenterInterface $renderers = array(); foreach ($envelopes as $envelope) { - $rendererStamp = $envelope->get('Flasher\Prime\TestsStamp\HandlerStamp'); + $rendererStamp = $envelope->get('Flasher\Prime\Stamp\HandlerStamp'); if (in_array($rendererStamp->getHandler(), $renderers)) { continue; } @@ -115,7 +115,7 @@ abstract class AbstractPresenter implements PresenterInterface $renderers = array(); foreach ($envelopes as $envelope) { - $rendererStamp = $envelope->get('Flasher\Prime\TestsStamp\HandlerStamp'); + $rendererStamp = $envelope->get('Flasher\Prime\Stamp\HandlerStamp'); if (in_array($rendererStamp->getHandler(), $renderers)) { continue; } @@ -143,7 +143,7 @@ abstract class AbstractPresenter implements PresenterInterface $renderers = array(); foreach ($envelopes as $envelope) { - $rendererStamp = $envelope->get('Flasher\Prime\TestsStamp\HandlerStamp'); + $rendererStamp = $envelope->get('Flasher\Prime\Stamp\HandlerStamp'); if (in_array($rendererStamp->getHandler(), $renderers)) { continue; } @@ -159,4 +159,9 @@ abstract class AbstractPresenter implements PresenterInterface return array_values(array_filter(array_unique($options))); } + + public function hasNotifications() + { + + } } diff --git a/Presenter/Adapter/HtmlPresenter.php b/Presenter/Adapter/HtmlPresenter.php index 45245f61..7c16a0a7 100644 --- a/Presenter/Adapter/HtmlPresenter.php +++ b/Presenter/Adapter/HtmlPresenter.php @@ -1,8 +1,8 @@ get('Flasher\Prime\TestsStamp\HandlerStamp'); + $rendererStamp = $envelope->get('Flasher\Prime\Stamp\HandlerStamp'); $renderer = $this->rendererManager->make($rendererStamp->getHandler()); $html .= $renderer->render($envelope).PHP_EOL; @@ -72,7 +72,7 @@ HTML; } /** - * @param \Notify\Envelope[] $envelopes + * @param \Flasher\Prime\Envelope[] $envelopes * * @return string */ @@ -88,7 +88,7 @@ HTML; } /** - * @param \Notify\Envelope[] $envelopes + * @param \Flasher\Prime\Envelope[] $envelopes * * @return string */ diff --git a/Presenter/Adapter/JsonPresenter.php b/Presenter/Adapter/JsonPresenter.php index bdb77d42..7fe4280e 100644 --- a/Presenter/Adapter/JsonPresenter.php +++ b/Presenter/Adapter/JsonPresenter.php @@ -1,8 +1,8 @@ get('Flasher\Prime\TestsStamp\HandlerStamp'); + $rendererStamp = $envelope->get('Flasher\Prime\Stamp\HandlerStamp'); $renderer = $this->rendererManager->make($rendererStamp->getHandler()); $notifications[] = array( diff --git a/Presenter/PresenterInterface.php b/Presenter/PresenterInterface.php index 43c69c2c..7cbc47a8 100644 --- a/Presenter/PresenterInterface.php +++ b/Presenter/PresenterInterface.php @@ -1,6 +1,6 @@ createdAt = $createdAt ?: new \DateTime('now', new \DateTimeZone('Africa/Casablanca')); + $this->createdAt = $createdAt ?: new DateTime('now', new DateTimeZone('Africa/Casablanca')); } /** - * @return \DateTime + * @return DateTime */ public function getCreatedAt() { @@ -28,7 +32,7 @@ final class CreatedAtStamp implements StampInterface, OrderableStampInterface } /** - * @param \Flasher\Prime\TestsStamp\OrderableStampInterface $orderable + * @param OrderableStampInterface $orderable * * @return int */ diff --git a/Stamp/HandlerStamp.php b/Stamp/HandlerStamp.php index 7e2252bd..f9c2d667 100644 --- a/Stamp/HandlerStamp.php +++ b/Stamp/HandlerStamp.php @@ -1,6 +1,6 @@ renderedAt = $renderedAt ?: new \DateTime('now', new \DateTimeZone('Africa/Casablanca')); + $this->renderedAt = $renderedAt ?: new DateTime('now', new DateTimeZone('Africa/Casablanca')); } /** - * @return \DateTime + * @return DateTime */ public function getRenderedAt() { diff --git a/Stamp/StampInterface.php b/Stamp/StampInterface.php index e87df488..1788bc60 100644 --- a/Stamp/StampInterface.php +++ b/Stamp/StampInterface.php @@ -1,6 +1,6 @@ + * @return array */ public static function indexWithUuid($envelopes) { @@ -39,7 +41,7 @@ final class UuidStamp implements StampInterface $map = array(); foreach ($envelopes as $envelope) { - $uuid = $envelope->get('Flasher\Prime\TestsStamp\UuidStamp')->getUuid(); + $uuid = $envelope->get('Flasher\Prime\Stamp\UuidStamp')->getUuid(); $map[$uuid] = $envelope; } diff --git a/Storage/ArrayStorage.php b/Storage/ArrayStorage.php index 8c51fde3..46c1d98e 100644 --- a/Storage/ArrayStorage.php +++ b/Storage/ArrayStorage.php @@ -1,9 +1,9 @@ get('Flasher\Prime\TestsStamp\UuidStamp')) { + if (null === $envelope->get('Flasher\Prime\Stamp\UuidStamp')) { $envelope->withStamp(new UuidStamp()); } @@ -37,7 +37,7 @@ final class ArrayStorage implements StorageInterface } /** - * @param \Notify\Envelope[] $envelopes + * @param Envelope[] $envelopes */ public function remove($envelopes) { @@ -48,7 +48,7 @@ final class ArrayStorage implements StorageInterface $this->envelopes = array_filter( $this->envelopes, function (Envelope $envelope) use ($map) { - $uuid = $envelope->get('Flasher\Prime\TestsStamp\UuidStamp')->getUuid(); + $uuid = $envelope->get('Flasher\Prime\Stamp\UuidStamp')->getUuid(); return !isset($map[$uuid]); } diff --git a/Storage/StorageInterface.php b/Storage/StorageInterface.php index 349f6b68..714ac135 100644 --- a/Storage/StorageInterface.php +++ b/Storage/StorageInterface.php @@ -1,21 +1,23 @@ storage->remove($envelopes); foreach ($envelopes as $envelope) { - $replayStamp = $envelope->get('Flasher\Prime\TestsStamp\ReplayStamp'); + $replayStamp = $envelope->get('Flasher\Prime\Stamp\HopsStamp'); $replayCount = null === $replayStamp ? 0 : $replayStamp->getCount() - 1; if (1 > $replayCount) { continue; } - $envelope->with(new ReplayStamp($replayCount)); + $envelope->with(new HopsStamp($replayCount)); $this->storage->add($envelope); } } diff --git a/Storage/StorageManagerInterface.php b/Storage/StorageManagerInterface.php index 62acb8cd..f75e62ed 100644 --- a/Storage/StorageManagerInterface.php +++ b/Storage/StorageManagerInterface.php @@ -1,28 +1,28 @@ getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); - $stamp = $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); + $stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(); $envelope = new Envelope($notification, array($stamp)); @@ -20,9 +20,9 @@ final class EnvelopeTest extends TestCase public function testWith() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); - $stamp1 = $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(); - $stamp2 = $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); + $stamp1 = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(); + $stamp2 = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(); $envelope = new Envelope($notification); $envelope->with($stamp1, $stamp2); @@ -33,8 +33,8 @@ final class EnvelopeTest extends TestCase public function testWrap() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); - $stamp = $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); + $stamp = $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(); $envelope = Envelope::wrap($notification, array($stamp)); @@ -44,12 +44,12 @@ final class EnvelopeTest extends TestCase public function testAll() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); $stamps = array( - $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), ); $envelope = new Envelope($notification, $stamps); @@ -60,14 +60,14 @@ final class EnvelopeTest extends TestCase public function testGet() { - $notification = $this->getMockBuilder('\Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); + $notification = $this->getMockBuilder('\Flasher\Prime\Notification\NotificationInterface')->getMock(); $stamps = array( - $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsStamp\StampInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Stamp\StampInterface')->getMock(), ); - $envelope = new \Notify\Envelope($notification, $stamps); + $envelope = new \Flasher\Prime\Envelope($notification, $stamps); $this->assertSame($notification, $envelope->getNotification()); diff --git a/Tests/Envelope/Stamp/CreatedAtStampTest.php b/Tests/Envelope/Stamp/CreatedAtStampTest.php index e1eb5b92..4c340e65 100644 --- a/Tests/Envelope/Stamp/CreatedAtStampTest.php +++ b/Tests/Envelope/Stamp/CreatedAtStampTest.php @@ -2,30 +2,30 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; -use Notify\Envelope; -use Flasher\Prime\TestsStamp\CreatedAtStamp; -use Flasher\Prime\TestsStamp\ReplayStamp; +use Flasher\Prime\Envelope; +use Flasher\Prime\Stamp\CreatedAtStamp; +use Flasher\Prime\Stamp\HopsStamp; use PHPUnit\Framework\TestCase; final class CreatedAtStampTest extends TestCase { public function testConstruct() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); $stamp = new CreatedAtStamp(); $envelop = new Envelope($notification, array($stamp)); - $this->assertSame($stamp, $envelop->get('Flasher\Prime\TestsStamp\CreatedAtStamp')); - $this->assertInstanceOf('Flasher\Prime\TestsStamp\StampInterface', $stamp); + $this->assertSame($stamp, $envelop->get('Flasher\Prime\Stamp\CreatedAtStamp')); + $this->assertInstanceOf('Flasher\Prime\Stamp\StampInterface', $stamp); } public function testCompare() { - $createdAt1 = new \Flasher\Prime\TestsStamp\CreatedAtStamp(new \DateTime('+2 h')); - $createdAt2 = new \Flasher\Prime\TestsStamp\CreatedAtStamp(new \DateTime('+1 h')); + $createdAt1 = new \Flasher\Prime\Stamp\CreatedAtStamp(new \DateTime('+2 h')); + $createdAt2 = new \Flasher\Prime\Stamp\CreatedAtStamp(new \DateTime('+1 h')); $this->assertFalse($createdAt1->compare($createdAt2)); - $this->assertSame(0, $createdAt1->compare(new ReplayStamp(1))); + $this->assertSame(0, $createdAt1->compare(new HopsStamp(1))); } } diff --git a/Tests/Envelope/Stamp/LifeStampTest.php b/Tests/Envelope/Stamp/LifeStampTest.php index 13ae149a..d8b42a2f 100644 --- a/Tests/Envelope/Stamp/LifeStampTest.php +++ b/Tests/Envelope/Stamp/LifeStampTest.php @@ -2,20 +2,20 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; -use Notify\Envelope; +use Flasher\Prime\Envelope; use PHPUnit\Framework\TestCase; final class LifeStampTest extends TestCase { public function testConstruct() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); - $stamp = new \Flasher\Prime\TestsStamp\ReplayStamp(5); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); + $stamp = new \Flasher\Prime\Stamp\HopsStamp(5); $envelop = new Envelope($notification, array($stamp)); - $this->assertSame($stamp, $envelop->get('Flasher\Prime\TestsStamp\ReplayStamp')); - $this->assertInstanceOf('Flasher\Prime\TestsStamp\ReplayStamp', $stamp); + $this->assertSame($stamp, $envelop->get('Flasher\Prime\Stamp\HopsStamp')); + $this->assertInstanceOf('Flasher\Prime\Stamp\HopsStamp', $stamp); $this->assertSame(5, $stamp->getCount()); } } diff --git a/Tests/Envelope/Stamp/PriorityStampTest.php b/Tests/Envelope/Stamp/PriorityStampTest.php index bc73f7e7..92ba7a7a 100644 --- a/Tests/Envelope/Stamp/PriorityStampTest.php +++ b/Tests/Envelope/Stamp/PriorityStampTest.php @@ -2,30 +2,30 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; -use Notify\Envelope; -use Flasher\Prime\TestsStamp\PriorityStamp; +use Flasher\Prime\Envelope; +use Flasher\Prime\Stamp\PriorityStamp; use PHPUnit\Framework\TestCase; final class PriorityStampTest extends TestCase { public function testConstruct() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); $stamp = new PriorityStamp(5); $envelop = new Envelope($notification, array($stamp)); - $this->assertSame($stamp, $envelop->get('Flasher\Prime\TestsStamp\PriorityStamp')); - $this->assertInstanceOf('Flasher\Prime\TestsStamp\StampInterface', $stamp); + $this->assertSame($stamp, $envelop->get('Flasher\Prime\Stamp\PriorityStamp')); + $this->assertInstanceOf('Flasher\Prime\Stamp\StampInterface', $stamp); $this->assertSame(5, $stamp->getPriority()); } public function testCompare() { $stamp1 = new PriorityStamp(1); - $stamp2 = new \Flasher\Prime\TestsStamp\PriorityStamp(2); + $stamp2 = new \Flasher\Prime\Stamp\PriorityStamp(2); $this->assertFalse($stamp1->compare($stamp2)); - $this->assertSame(0, $stamp1->compare(new \Flasher\Prime\TestsStamp\ReplayStamp(1))); + $this->assertSame(0, $stamp1->compare(new \Flasher\Prime\Stamp\HopsStamp(1))); } } diff --git a/Tests/Envelope/Stamp/RendererStampTest.php b/Tests/Envelope/Stamp/RendererStampTest.php index 712d47cc..d5661546 100644 --- a/Tests/Envelope/Stamp/RendererStampTest.php +++ b/Tests/Envelope/Stamp/RendererStampTest.php @@ -2,20 +2,20 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; -use Notify\Envelope; +use Flasher\Prime\Envelope; use PHPUnit\Framework\TestCase; final class RendererStampTest extends TestCase { public function testConstruct() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); - $stamp = new \Flasher\Prime\TestsStamp\HandlerStamp('toastr'); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); + $stamp = new \Flasher\Prime\Stamp\HandlerStamp('toastr'); $envelop = new Envelope($notification, array($stamp)); - $this->assertSame($stamp, $envelop->get('Flasher\Prime\TestsStamp\HandlerStamp')); - $this->assertInstanceOf('Flasher\Prime\TestsStamp\HandlerStamp', $stamp); + $this->assertSame($stamp, $envelop->get('Flasher\Prime\Stamp\HandlerStamp')); + $this->assertInstanceOf('Flasher\Prime\Stamp\HandlerStamp', $stamp); $this->assertSame('toastr', $stamp->getHandler()); } } diff --git a/Tests/Envelope/Stamp/UuidStampTest.php b/Tests/Envelope/Stamp/UuidStampTest.php index f96cda32..b1a2ef3c 100644 --- a/Tests/Envelope/Stamp/UuidStampTest.php +++ b/Tests/Envelope/Stamp/UuidStampTest.php @@ -2,20 +2,20 @@ namespace Flasher\Prime\Tests\Envelope\Stamp; -use Notify\Envelope; +use Flasher\Prime\Envelope; use PHPUnit\Framework\TestCase; final class UuidStampTest extends TestCase { public function testConstruct() { - $notification = $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(); - $stamp = new \Flasher\Prime\TestsStamp\UuidStamp(); + $notification = $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(); + $stamp = new \Flasher\Prime\Stamp\UuidStamp(); $envelop = new Envelope($notification, array($stamp)); - $this->assertSame($stamp, $envelop->get('Flasher\Prime\TestsStamp\UuidStamp')); - $this->assertInstanceOf('Flasher\Prime\TestsStamp\UuidStamp', $stamp); + $this->assertSame($stamp, $envelop->get('Flasher\Prime\Stamp\UuidStamp')); + $this->assertInstanceOf('Flasher\Prime\Stamp\UuidStamp', $stamp); $this->assertNotEmpty($stamp->getUuid()); } } diff --git a/Tests/Filter/CriteriaBuilderTest.php b/Tests/Filter/CriteriaBuilderTest.php index 9cc5f07a..a661b648 100644 --- a/Tests/Filter/CriteriaBuilderTest.php +++ b/Tests/Filter/CriteriaBuilderTest.php @@ -2,8 +2,8 @@ namespace Flasher\Prime\Tests\Filter; -use Flasher\Prime\TestsFilter\CriteriaBuilder; -use Flasher\Prime\TestsFilter\FilterBuilder; +use Flasher\Prime\Filter\CriteriaBuilder; +use Flasher\Prime\Filter\FilterBuilder; use Flasher\Prime\Tests\TestCase; final class CriteriaBuilderTest extends TestCase @@ -12,14 +12,14 @@ final class CriteriaBuilderTest extends TestCase { $criteria = new CriteriaBuilder( new FilterBuilder(), array( - 'priority' => 1, - 'life' => 2, - 'limit' => 2, - 'order_by' => 'Flasher\Prime\TestsStamp\ReplayStamp', + 'priority' => 1, + 'life' => 2, + 'limit' => 2, + 'order_by' => 'Flasher\Prime\Stamp\HopsStamp', ) ); - $this->assertInstanceOf('Flasher\Prime\TestsFilter\FilterBuilder', $criteria->build()); + $this->assertInstanceOf('Flasher\Prime\Filter\FilterBuilder', $criteria->build()); $this->assertNotEmpty($criteria->build()->getSpecification()); } @@ -27,7 +27,7 @@ final class CriteriaBuilderTest extends TestCase { $criteria = new CriteriaBuilder(new FilterBuilder(), array()); - $this->assertInstanceOf('Flasher\Prime\TestsFilter\FilterBuilder', $criteria->build()); + $this->assertInstanceOf('Flasher\Prime\Filter\FilterBuilder', $criteria->build()); $this->assertEmpty($criteria->build()->getSpecification()); } } diff --git a/Tests/Filter/DefaultFilterTest.php b/Tests/Filter/DefaultFilterTest.php index f192a292..bbe974fd 100644 --- a/Tests/Filter/DefaultFilterTest.php +++ b/Tests/Filter/DefaultFilterTest.php @@ -3,10 +3,10 @@ namespace Flasher\Prime\Tests\Filter; use Notify\Config\Config; -use Notify\Envelope; -use Flasher\Prime\TestsMiddleware\AddCreatedAtStampMiddleware; -use Flasher\Prime\TestsMiddleware\AddPriorityStampMiddleware; -use Flasher\Prime\TestsStamp\PriorityStamp; +use Flasher\Prime\Envelope; +use Flasher\Prime\Middleware\AddCreatedAtStampMiddleware; +use Flasher\Prime\Middleware\AddPriorityStampMiddleware; +use Flasher\Prime\Stamp\PriorityStamp; use Flasher\Prime\Tests\TestCase; final class DefaultFilterTest extends TestCase @@ -14,23 +14,23 @@ final class DefaultFilterTest extends TestCase public function testWithCriteria() { $notifications = array( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), ); $notifications[3] = new Envelope( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), array(new PriorityStamp(5)) ); $notifications[4] = new Envelope( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), array(new PriorityStamp(-1)) ); $notifications[5] = new Envelope( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), array(new PriorityStamp(1)) ); diff --git a/Tests/Filter/FilterManagerTest.php b/Tests/Filter/FilterManagerTest.php index 6d5004c2..29ef137c 100644 --- a/Tests/Filter/FilterManagerTest.php +++ b/Tests/Filter/FilterManagerTest.php @@ -3,13 +3,13 @@ namespace Flasher\Prime\Tests\Filter; use Notify\Config\Config; -use Notify\Envelope; -use Flasher\Prime\TestsFilter\FilterBuilder; -use Flasher\Prime\TestsFilter\Specification\PrioritySpecification; -use Flasher\Prime\TestsMiddleware\AddCreatedAtStampMiddleware; -use Flasher\Prime\TestsMiddleware\AddPriorityStampMiddleware; -use Flasher\Prime\TestsMiddleware\NotifyBus; -use Flasher\Prime\TestsStamp\PriorityStamp; +use Flasher\Prime\Envelope; +use Flasher\Prime\Filter\FilterBuilder; +use Flasher\Prime\Filter\Specification\PrioritySpecification; +use Flasher\Prime\Middleware\AddCreatedAtStampMiddleware; +use Flasher\Prime\Middleware\AddPriorityStampMiddleware; +use Flasher\Prime\MiddlewareFlasher\PrimeBus; +use Flasher\Prime\Stamp\PriorityStamp; use PHPUnit\Framework\TestCase; final class FilterManagerTest extends TestCase @@ -17,23 +17,23 @@ final class FilterManagerTest extends TestCase public function testFilterWhere() { $notifications = array( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), ); $notifications[3] = new Envelope( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), array(new PriorityStamp(5)) ); $notifications[4] = new Envelope( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), array(new PriorityStamp(-1)) ); $notifications[5] = new Envelope( - $this->getMockBuilder('Flasher\Prime\TestsNotification\NotificationInterface')->getMock(), + $this->getMockBuilder('Flasher\Prime\Notification\NotificationInterface')->getMock(), array(new PriorityStamp(1)) ); @@ -68,7 +68,7 @@ final class FilterManagerTest extends TestCase ->andWhere(new PrioritySpecification(1, 5)) ->orderBy( array( - 'Flasher\Prime\TestsStamp\PriorityStamp' => 'ASC' + 'Flasher\Prime\Stamp\PriorityStamp' => 'ASC' ) ) ->setMaxResults(2) @@ -83,8 +83,8 @@ final class FilterManagerTest extends TestCase ->orWhere(new PrioritySpecification(1, 5)) ->orderBy( array( - 'Flasher\Prime\TestsStamp\PriorityStamp' => 'ASC', - 'Notify\Envelope\Stamp\NotExists' => 'ASC', + 'Flasher\Prime\Stamp\PriorityStamp' => 'ASC', + 'Flasher\Prime\Envelope\Stamp\NotExists' => 'ASC', ) ) ->setMaxResults(2) diff --git a/Tests/Manager/ManagerTest.php b/Tests/Manager/ManagerTest.php index 97eafcd1..d37b1677 100644 --- a/Tests/Manager/ManagerTest.php +++ b/Tests/Manager/ManagerTest.php @@ -2,7 +2,7 @@ namespace Flasher\Prime\Tests\Manager; -use Notify\Notify; +use NotifyFlasher\Prime; use Flasher\Prime\Tests\TestCase; final class ManagerTest extends TestCase @@ -27,7 +27,7 @@ final class ManagerTest extends TestCase $manager = new Notify($config); - $producer = $this->getMockBuilder('Notify\NotifyFactory')->getMock(); + $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); $producer->method('supports')->willReturn(true); $manager->addDriver($producer); @@ -45,7 +45,7 @@ final class ManagerTest extends TestCase $manager = new Notify($config); - $producer = $this->getMockBuilder('Notify\NotifyFactory')->getMock(); + $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); $manager->addDriver($producer); $manager->make('test_driver'); diff --git a/Tests/Notification/NotificationTest.php b/Tests/Notification/NotificationTest.php index bdbfdbe9..4e82f2cf 100644 --- a/Tests/Notification/NotificationTest.php +++ b/Tests/Notification/NotificationTest.php @@ -2,7 +2,7 @@ namespace Flasher\Prime\Tests\Notification; -use Flasher\Prime\TestsNotification\Notification; +use Flasher\Prime\Notification\Notification; use Flasher\Prime\Tests\TestCase; final class NotificationTest extends TestCase diff --git a/Tests/Producer/ProducerManagerTest.php b/Tests/Producer/ProducerManagerTest.php index 7ce0382e..e015d61f 100644 --- a/Tests/Producer/ProducerManagerTest.php +++ b/Tests/Producer/ProducerManagerTest.php @@ -10,9 +10,9 @@ final class ProducerManagerTest extends TestCase public function testExtendToAddMoreNotifiersFactory() { $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); - $manager = new \Notify\Notify($config); + $manager = new Flasher\PrimeFlasher\Prime($config); - $producer = $this->getMockBuilder('Notify\NotifyFactory')->getMock(); + $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); $producer->method('supports')->willReturn(true); $manager->addDriver($producer); @@ -34,9 +34,9 @@ final class ProducerManagerTest extends TestCase $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); $config->method('get')->willReturn(null); - $manager = new \Notify\Notify($config); + $manager = new Flasher\PrimeFlasher\Prime($config); - $producer = $this->getMockBuilder('Notify\NotifyFactory')->getMock(); + $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); $manager->addDriver($producer); $this->assertSame($producer, $manager->make()); @@ -47,9 +47,9 @@ final class ProducerManagerTest extends TestCase $this->setExpectedException('InvalidArgumentException', 'Driver [not_supported] not supported.'); $config = $this->getMockBuilder('Notify\Config\ConfigInterface')->getMock(); - $manager = new \Notify\Notify($config); + $manager = new Flasher\PrimeFlasher\Prime($config); - $producer = $this->getMockBuilder('Notify\NotifyFactory')->getMock(); + $producer = $this->getMockBuilder('NotifyFlasher\PrimeFactory')->getMock(); $manager->addDriver($producer); $this->assertSame($producer, $manager->make('not_supported')); diff --git a/Tests/Storage/ArrayStorageTest.php b/Tests/Storage/ArrayStorageTest.php index 54896f2d..97e797fc 100644 --- a/Tests/Storage/ArrayStorageTest.php +++ b/Tests/Storage/ArrayStorageTest.php @@ -2,10 +2,10 @@ namespace Flasher\Prime\Tests\Storage; -use Notify\Envelope; -use Flasher\Prime\TestsNotification\Notification; -use Flasher\Prime\TestsStamp\UuidStamp; -use Flasher\Prime\TestsStorage\ArrayStorage; +use Flasher\Prime\Envelope; +use Flasher\Prime\Notification\Notification; +use Flasher\Prime\Stamp\UuidStamp; +use Flasher\Prime\Storage\ArrayStorage; use Flasher\Prime\Tests\TestCase; final class ArrayStorageTest extends TestCase @@ -32,7 +32,7 @@ final class ArrayStorageTest extends TestCase $this->assertCount(1, $envelopes); - $uuid = $envelopes[0]->get('Flasher\Prime\TestsStamp\UuidStamp'); + $uuid = $envelopes[0]->get('Flasher\Prime\Stamp\UuidStamp'); $this->assertNotNull($uuid); } diff --git a/Tests/Storage/StorageManagerTest.php b/Tests/Storage/StorageManagerTest.php index b3dddd65..9ef22b1f 100644 --- a/Tests/Storage/StorageManagerTest.php +++ b/Tests/Storage/StorageManagerTest.php @@ -2,12 +2,12 @@ namespace Flasher\Prime\Tests\Storage; -use Notify\Envelope; -use Flasher\Prime\TestsNotification\Notification; -use Flasher\Prime\TestsStamp\ReplayStamp; -use Flasher\Prime\TestsStamp\UuidStamp; -use Flasher\Prime\TestsStorage\ArrayStorage; -use Flasher\Prime\TestsStorage\StorageManager; +use Flasher\Prime\Envelope; +use Flasher\Prime\Notification\Notification; +use Flasher\Prime\Stamp\HopsStamp; +use Flasher\Prime\Stamp\UuidStamp; +use Flasher\Prime\Storage\ArrayStorage; +use Flasher\Prime\Storage\StorageManager; use PHPUnit\Framework\TestCase; class StorageManagerTest extends TestCase @@ -49,7 +49,7 @@ class StorageManagerTest extends TestCase $this->assertCount(1, $envelopes); - $uuid = $envelopes[0]->get('Flasher\Prime\TestsStamp\UuidStamp'); + $uuid = $envelopes[0]->get('Flasher\Prime\Stamp\UuidStamp'); $this->assertNotNull($uuid); } @@ -59,7 +59,7 @@ class StorageManagerTest extends TestCase $envelope = new Envelope( new Notification('error message', 'error'), - new ReplayStamp(2), + new HopsStamp(2), new UuidStamp('fake-uuid') ); $storageManager->add($envelope); diff --git a/Translator/TranslatorInterface.php b/Translator/TranslatorInterface.php new file mode 100644 index 00000000..620f7bdf --- /dev/null +++ b/Translator/TranslatorInterface.php @@ -0,0 +1,8 @@ +