EventServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 1
1
<?php
2
/*
3
* The MIT License (MIT)
4
* Copyright © 2017 Marcos Lois Bermudez <[email protected]>
5
* *
6
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7
* documentation files (the “Software”), to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
* *
11
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
12
* of the Software.
13
* *
14
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
* DEALINGS IN THE SOFTWARE.
19
*/
20
21
namespace TTIC\Laravel\Bridge\Event;
22
23
use Illuminate\Contracts\Foundation\Application;
24
use Illuminate\Support\ServiceProvider;
25
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
26
27
/**
28
 * A Laravel service provider that register a event listener that is
29
 * compatible with Symfony EventDispatcherInterface, and a
30
 * EventDispatcherInterface alias to allow resolver to inject this type.
31
 *
32
 * @package TTIC\Laravel\Bridge\Event
33
 * @author Marcos Lois Bermúdez <[email protected]>
34
 */
35
class EventServiceProvider extends ServiceProvider
36
{
37
    /**
38
     * Register the service provider.
39
     *
40
     * @return void
41
     */
42
    public function register()
43
    {
44
        $this->app->singleton('events', function (Application $app) {
45
            return (new EventDispatcher($app))->setQueueResolver(function () use ($app) {
46
                return $app->make('Illuminate\Contracts\Queue\Factory');
47
            });
48
        });
49
50
        // Register a alias for the Symfony interface
51
        $this->app->alias(EventDispatcherInterface::class, 'events');
52
    }
53
}
54