IMServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A publishFiles() 0 5 1
A register() 0 23 1
A provides() 0 3 1
1
<?php
2
3
namespace CTL\XMPPMessageBase;
4
5
use BirknerAlex\XMPPHP\XMPP;
6
use Illuminate\Support\ServiceProvider;
7
8
class IMServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->publishFiles();
18
    }
19
20
    /**
21
     * Publishes files that package needs
22
     */
23
    public function publishFiles(){
24
        $this->publishes([
25
            __DIR__.'/config/im.php' => config_path('im.php'),
26
         ]);
27
    }
28
29
    /**
30
     * Register the application services.
31
     *
32
     * @return void
33
     */
34
    public function register()
35
    {
36
37
        $this->app->bind('IM', function(){
38
            // Configuration variables for XMPP
39
            $host = config('services.xmpp.host');
40
            $port = config('services.xmpp.port');
41
            $user = config('services.xmpp.user');
42
            $password = config('services.xmpp.password');
43
            $resource = \Session::getId();
44
45
            $im = new XMPP(
46
                $host, $port, $user, $password, $resource
47
            );
48
49
            $im->connect();
50
            $im->processUntil('session_started', 1);
51
52
            return $im;
53
        });
54
55
56
    }
57
58
    /**
59
     * [provides description]
60
     * @return void
61
     */
62
    public function provides(){
63
        return ['IM'];
64
    }
65
66
}
67