Completed
Pull Request — master (#23)
by
unknown
02:30
created

QwatcherServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 52
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 1
A register() 0 14 1
A provides() 0 4 1
1
<?php namespace Maqe\Qwatcher;
2
3
use Queue;
4
use Illuminate\Support\ServiceProvider;
5
use Illuminate\Support\Facades\Log;
6
use Maqe\Qwatcher\Facades\Qwatch;
7
use Maqe\Qwatcher\Tracks\FailedTracks;
8
use Maqe\Qwatcher\Tracks\ProcessTracks;
9
use Maqe\Qwatcher\Tracks\SucceedTracks;
10
11
class QwatcherServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap any application services.
15
     *
16
     * @return void
17
     */
18
    public function boot()
19
    {
20
        Queue::before(function ($job) {
21
            Qwatch::tracks(new ProcessTracks($job->job->getJobId(), $job->job));
22
        });
23
24
        Queue::after(function ($job) {
25
            Qwatch::tracks(new SucceedTracks($job->job->getJobId(), $job->job));
26
        });
27
28
        Queue::failing(function ($job) {
29
            Qwatch::tracks(new FailedTracks($job->job->getJobId(), $job->job));
30
        });
31
    }
32
33
    /**
34
     * Register the service provider.
35
     *
36
     * @return void
37
     */
38
    public function register()
39
    {
40
        /**
41
        * publish migrations
42
        */
43
        $this->publishes([__DIR__ . '/../database/migrations' => database_path('migrations')], 'migrations');
44
45
        /**
46
        * Register Facade
47
        */
48
        $this->app->bind('Qwatch', function () {
49
            return (new Qwatcher);
50
        });
51
    }
52
53
    /**
54
     * Get the services provided by the provider.
55
     *
56
     * @return array
57
     */
58
    public function provides()
59
    {
60
        return ['Qwatch'];
61
    }
62
}
63