Completed
Push — master ( f95f21...230596 )
by Rudy
03:16
created

IMServiceProvider::publishFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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