ConsoleTaskerProvider   A
last analyzed

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\Facades\Config;
10
use Illuminate\Support\ServiceProvider;
11
use Symfony\Component\Console\Input\ArgvInput;
12
use Symfony\Component\Console\Output\ConsoleOutput;
13
14
/**
15
 * The console tasker provider.
16
 *
17
 */
18
class ConsoleTaskerProvider extends ServiceProvider
19
{
20
    /**
21
     * The configuration file path.
22
     *
23
     * @var string
24
     */
25
    protected const CONFIG = __DIR__ . '/../../config/console_tasker.php';
26
27
    /**
28
     * Bootstrap the application services.
29
     *
30
     * @return void
31
     */
32
    public function boot()
33
    {
34
        if ($this->app->runningInConsole()) {
35
            $this->commands(MakeConsoleTaskerCommand::class);
36
        }
37
38
        $this->publishes([
39
            static::CONFIG => $this->app->configPath('console_tasker.php')
40
        ], 'console_tasker');
41
    }
42
43
    /**
44
     * Register the bindings
45
     *
46
     * @return void
47
     */
48
    public function register()
49
    {
50
        $this->mergeConfigFrom(static::CONFIG, 'console_tasker');
51
52
        $this->app->bind(DefaultPrinter::class, function () {
53
            return new DefaultPrinter(new OutputStyle(new ArgvInput(), new ConsoleOutput()));
54
        });
55
56
        $this->app->bind(PrinterInterface::class, Config::get('console_tasker.printer'));
57
    }
58
}
59