QueueServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 14
c 1
b 0
f 1
dl 0
loc 51
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A registerMessageMapper() 0 9 1
A register() 0 5 1
A registerMessageFactory() 0 7 1
A registerDestinationFactory() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\Queue;
6
7
use Pimple\Container;
8
use Pimple\ServiceProviderInterface;
9
10
class QueueServiceProvider implements ServiceProviderInterface
11
{
12
    /**
13
     * @param Container $container
14
     *
15
     * @return void
16
     */
17
    public function register(Container $container): void
18
    {
19
        $this->registerMessageFactory($container)
20
            ->registerMessageMapper($container)
21
            ->registerDestinationFactory($container);
22
    }
23
24
    /**
25
     * @param \Pimple\Container $container
26
     *
27
     * @return \Jellyfish\Queue\QueueServiceProvider
28
     */
29
    protected function registerMessageFactory(Container $container): QueueServiceProvider
30
    {
31
        $container->offsetSet(QueueConstants::CONTAINER_KEY_MESSAGE_FACTORY, static function () {
32
            return new MessageFactory();
33
        });
34
35
        return $this;
36
    }
37
38
    /**
39
     * @param \Pimple\Container $container
40
     *
41
     * @return \Jellyfish\Queue\QueueServiceProvider
42
     */
43
    protected function registerMessageMapper(Container $container): QueueServiceProvider
44
    {
45
        $container->offsetSet(QueueConstants::CONTAINER_KEY_MESSAGE_MAPPER, static function (Container $container) {
46
            return new MessageMapper(
47
                $container->offsetGet('serializer')
48
            );
49
        });
50
51
        return $this;
52
    }
53
54
    protected function registerDestinationFactory(Container $container): QueueServiceProvider
55
    {
56
        $container->offsetSet(QueueConstants::CONTAINER_KEY_DESTINATION_FACTORY, static function () {
57
            return new DestinationFactory();
58
        });
59
60
        return $this;
61
    }
62
}
63