Passed
Pull Request — main (#42)
by Luke
09:39
created

BatchQueueServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 3 Features 0
Metric Value
wmc 3
eloc 12
c 4
b 3
f 0
dl 0
loc 34
ccs 0
cts 13
cp 0
rs 10

3 Methods

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