This commit is contained in:
Carlos Buenosvinos
2022-03-19 01:56:07 +01:00
parent 8bfa5ef872
commit 92306c8a12

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Cheeper\Chapter8\Application\Author\Projection;
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjection;
use Cheeper\Chapter7\Application\Author\Projection\CreateFollowersCounterProjectionHandler;
use Redis;
//snippet projector-count-followers
final class CountFollowersProjectionHandler
{
public function __construct(
private Redis $redis
) {
}
public function __invoke(CountFollowersProjection $projection): void
{
$this->redis->hIncrBy(
sprintf(
CreateFollowersCounterProjectionHandler::REDIS_KEY_TEMPLATE,
$projection->authorId()
),
'followers',
1
);
}
}
//end-snippet