File size: 734 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
<?php

namespace Mautic\EmailBundle\Stats;

use Mautic\EmailBundle\Stats\Exception\InvalidStatHelperException;
use Mautic\EmailBundle\Stats\Helper\StatHelperInterface;

class StatHelperContainer
{
    /**
     * @var array<string, StatHelperInterface>
     */
    private array $helpers = [];

    public function addHelper(StatHelperInterface $helper): void
    {
        $this->helpers[$helper->getName()] = $helper;
    }

    /**
     * @throws InvalidStatHelperException
     */
    public function getHelper($name): StatHelperInterface
    {
        if (!isset($this->helpers[$name])) {
            throw new InvalidStatHelperException($name.' has not been registered');
        }

        return $this->helpers[$name];
    }
}