BatchQueueServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Laravel Queue for AWS Batch.
4
 *
5
 * @author    Luke Waite <[email protected]>
6
 * @copyright 2017 Luke Waite
7
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
8
 *
9
 * @link      https://github.com/dnxlabs/laravel-queue-aws-batch
10
 */
11
12
namespace DNXLabs\LaravelQueueAwsBatch;
13
14
use Illuminate\Support\ServiceProvider;
15
use DNXLabs\LaravelQueueAwsBatch\Connectors\BatchConnector;
16
use DNXLabs\LaravelQueueAwsBatch\Console\QueueWorkBatchCommand;
17
18
class BatchQueueServiceProvider extends ServiceProvider
19
{
20
    public function register()
21
    {
22
        $this->app->singleton(
23
            'command.queueawsbatch.work-batch',
24
            function ($app) {
25
                return new QueueWorkBatchCommand(
26
                    $app['queue'],
27
                    $app['queue.worker'],
28
                    $app['Illuminate\Foundation\Exceptions\Handler']
29
                );
30
            }
31
        );
32
33
        $this->commands('command.queueawsbatch.work-batch');
34
    }
35
36
    public function boot()
37
    {
38
        $this->registerBatchConnector($this->app['queue']);
39
    }
40
41
    /**
42
     * Register the Batch queue connector.
43
     *
44
     * @param \Illuminate\Queue\QueueManager $manager
45
     *
46
     * @return void
47
     */
48
    protected function registerBatchConnector($manager)
49
    {
50
        $manager->addConnector('batch', function () {
51
            return new BatchConnector($this->app['db']);
52
        });
53
    }
54
}
55