Completed
Push — master ( c2ba48...1fd225 )
by Markus
14s queued 12s
created

QueueServiceProvider::createRunJobCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Jellyfish\Queue;
4
5
use Pimple\Container;
6
use Pimple\ServiceProviderInterface;
7
use \Jellyfish\Serializer\SerializerInterface;
8
9
class QueueServiceProvider implements ServiceProviderInterface
10
{
11
    /**
12
     * @param Container $pimple A container instance
13
     *
14
     * @return void
15
     */
16
    public function register(Container $pimple): void
17
    {
18
        $self = $this;
19
20
        $pimple->offsetSet('message_factory', function () use ($self) {
21
            return $self->createMessageFactory();
22
        });
23
24
        $pimple->offsetSet('message_mapper', function (Container $container) use ($self) {
25
            return $self->createMessageMapper(
26
                $container->offsetGet('serializer')
27
            );
28
        });
29
    }
30
31
    /**
32
     * @param \Jellyfish\Serializer\SerializerInterface $serializer
33
     *
34
     * @return \Jellyfish\Queue\MessageMapperInterface
35
     */
36
    protected function createMessageMapper(
37
        SerializerInterface $serializer
38
    ): MessageMapperInterface {
39
        return new MessageMapper($serializer);
40
    }
41
42
    /**
43
     * @return \Jellyfish\Queue\MessageFactoryInterface
44
     */
45
    protected function createMessageFactory(): MessageFactoryInterface
46
    {
47
        return new MessageFactory();
48
    }
49
}
50