ServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 23 3
1
<?php
2
3
namespace Eole\Sandstone\Push;
4
5
use Pimple\ServiceProviderInterface;
6
use Pimple\Container;
7
8
class ServiceProvider implements ServiceProviderInterface
9
{
10
    /**
11
     * {@InheritDoc}
12
     */
13
    public function register(Container $app)
14
    {
15
        if (!$app->offsetExists('sandstone.push.enabled')) {
16
            $app['sandstone.push.enabled'] = true;
17
        }
18
19
        $app['sandstone.push.event_serializer'] = function () use ($app) {
20
            if (!$app->offsetExists('serializer')) {
21
                throw new \RuntimeException('A serializer must be registered');
22
            }
23
24
            return new EventSerializer($app['serializer']);
25
        };
26
27
        $app['sandstone.push.event_forwarder'] = function () use ($app) {
28
            return new EventForwarder(
29
                $app['sandstone.push'],
30
                $app['dispatcher'],
31
                $app['sandstone.push.event_serializer'],
32
                $app['sandstone.push.enabled']
33
            );
34
        };
35
    }
36
}
37