Passed
Push — master ( 889900...85cb36 )
by Keoghan
02:57
created

AppServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Providers;
4
5
use App\Porter;
6
use App\PorterLibrary;
7
use App\Support\Console\Cli;
8
use App\Support\Console\ConsoleWriter;
9
use App\Support\Console\ServerBag;
10
use App\Support\Contracts\Cli as CliContract;
11
use App\Support\Contracts\ImageSetRepository as ImageSetRepositoryContract;
12
use App\Support\FilePublisher;
13
use App\Support\Images\ImageSetRepository;
14
use App\Support\Images\Organiser\Organiser;
15
use App\Support\Ssl\CertificateBuilder;
16
use Illuminate\Filesystem\Filesystem;
17
use Illuminate\Support\ServiceProvider;
18
19
class AppServiceProvider extends ServiceProvider
20
{
21
    /**
22
     * Bootstrap any application services.
23
     */
24 90
    public function boot(): void
25
    {
26 90
        view()->getFinder()->prependLocation(app(PorterLibrary::class)->viewsPath());
27
28 90
        $this->app[ImageSetRepositoryContract::class]->registerViewNamespaces($this->app);
29 90
    }
30
31
    /**
32
     * Register any application services.
33
     */
34 90
    public function register(): void
35
    {
36
        $this->app->singleton(CertificateBuilder::class, function () {
37 5
            return new CertificateBuilder(
38 5
                app(CliContract::class),
39 5
                app(Filesystem::class),
40 5
                app(PorterLibrary::class)->sslPath()
41
            );
42 90
        });
43
44 90
        $this->app->bind(ConsoleWriter::class);
45
46 90
        $this->app->bind(CliContract::class, Cli::class);
47
48
        $this->app->bind(ImageSetRepositoryContract::class, function () {
49 90
            return new ImageSetRepository([
50 90
                resource_path('image_sets'),
51 90
                app(PorterLibrary::class)->dockerImagesPath(),
52
            ]);
53 90
        });
54
55
        $this->app->bind(Organiser::class, function () {
56
            return new Organiser(
57
                app(Porter::class)->getDockerImageSet(),
58
                app(CliContract::class),
59
                app(FileSystem::class)
60
            );
61 90
        });
62
63 90
        $this->app->singleton(Porter::class);
64
65
        $this->app->singleton(PorterLibrary::class, function () {
66 90
            return new PorterLibrary(app(FilePublisher::class), config('porter.library_path'));
67 90
        });
68
69 90
        $this->app->singleton(ServerBag::class);
70 90
    }
71
}
72