Passed
Push — master ( 32dee0...5d2de3 )
by Andrea Marco
13:08 queued 11s
created

ConsoleTaskerProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 39
ccs 0
cts 9
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 9 1
A boot() 0 9 2
1
<?php
2
3
namespace Cerbero\ConsoleTasker\Providers;
4
5
use Cerbero\ConsoleTasker\Console\Commands\MakeConsoleTaskerCommand;
6
use Cerbero\ConsoleTasker\Console\Printers\DefaultPrinter;
7
use Cerbero\ConsoleTasker\Console\Printers\PrinterInterface;
8
use Illuminate\Console\OutputStyle;
9
use Illuminate\Support\ServiceProvider;
10
use Symfony\Component\Console\Input\ArgvInput;
11
use Symfony\Component\Console\Output\ConsoleOutput;
12
13
/**
14
 * The console tasker provider.
15
 *
16
 */
17
class ConsoleTaskerProvider extends ServiceProvider
18
{
19
    /**
20
     * The configuration file path.
21
     *
22
     * @var string
23
     */
24
    protected const CONFIG = __DIR__ . '/../../config/console_tasker.php';
25
26
    /**
27
     * Bootstrap the application services.
28
     *
29
     * @return void
30
     */
31
    public function boot()
32
    {
33
        if ($this->app->runningInConsole()) {
34
            $this->commands(MakeConsoleTaskerCommand::class);
35
        }
36
37
        $this->publishes([
38
            static::CONFIG => $this->app->configPath('console_tasker.php')
39
        ], 'console_tasker');
40
    }
41
42
    /**
43
     * Register the bindings
44
     *
45
     * @return void
46
     */
47
    public function register()
48
    {
49
        $this->mergeConfigFrom(static::CONFIG, 'console_tasker');
50
51
        $this->app->bind(DefaultPrinter::class, function () {
52
            return new DefaultPrinter(new OutputStyle(new ArgvInput(), new ConsoleOutput()));
53
        });
54
55
        $this->app->bind(PrinterInterface::class, $this->app->config['console_tasker.printer']);
0 ignored issues
show
Bug introduced by
Accessing config on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
Bug introduced by
Accessing config on the interface Illuminate\Contracts\Fou...ion\CachesConfiguration suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
56
    }
57
}
58