File size: 721 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

namespace Mautic\SmsBundle\Callback;

use Mautic\SmsBundle\Exception\CallbackHandlerNotFound;

class HandlerContainer
{
    /**
     * @var CallbackInterface[]
     */
    private ?array $handlers = null;

    public function registerHandler(CallbackInterface $handler): void
    {
        $this->handlers[$handler->getTransportName()] = $handler;
    }

    /**
     * @return CallbackInterface
     *
     * @throws CallbackHandlerNotFound
     */
    public function getHandler($transportName)
    {
        if (!isset($this->handlers[$transportName])) {
            throw new CallbackHandlerNotFound("$transportName has not been registered");
        }

        return $this->handlers[$transportName];
    }
}