<?php

namespace App\Helper;

use Symfony\Component\Notifier\Chatter;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Exception\TransportExceptionInterface;
use Symfony\Component\Notifier\Message\ChatMessage;

class Slack
{
    private $chatter;

    public function __construct(ChatterInterface $chatter)
    {
        $this->chatter = $chatter;
    }

    public function sendMessage(String $message): void
    {
        $message = (new ChatMessage($message))
            ->transport('slack');

        try {
            $sentMessage = $this->chatter->send($message);
            dump($sentMessage);
        } catch (TransportExceptionInterface $e) {

        }
    }

}