<?php

namespace App\EntityListener;

use App\Entity\Domain\Stat;
use App\Message\StatUpdated;
use Symfony\Component\Messenger\MessageBusInterface;

final class StatListener
{
    /**
     * @var MessageBusInterface
     */
    private $bus;

    public function __construct(MessageBusInterface $bus)
    {
        $this->bus = $bus;
    }

    public function postUpdate(Stat $stat)
    {
        $this->bus->dispatch(new StatUpdated($stat->getDomain()));
    }
}
