Files
php-flasher/Middleware/AddCreatedAtStampMiddleware.php
T
2020-12-02 00:57:12 +01:00

19 lines
448 B
PHP

<?php
namespace Flasher\Prime\TestsMiddleware;
use Notify\Envelope;
use Flasher\Prime\TestsStamp\CreatedAtStamp;
final class AddCreatedAtStampMiddleware implements MiddlewareInterface
{
public function handle(Envelope $envelope, callable $next)
{
if (null === $envelope->get('Flasher\Prime\TestsStamp\CreatedAtStamp')) {
$envelope->withStamp(new CreatedAtStamp());
}
return $next($envelope);
}
}