Passed
Push — master ( 25b802...040228 )
by Darko
10:52
created

AdditionalProcessingServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 44
dl 0
loc 89
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 75 1
A boot() 0 2 1
1
<?php
2
3
namespace App\Providers;
4
5
use App\Services\AdditionalProcessing\AdditionalProcessingOrchestrator;
0 ignored issues
show
Bug introduced by
The type App\Services\AdditionalP...lProcessingOrchestrator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use App\Services\AdditionalProcessing\ArchiveExtractionService;
7
use App\Services\AdditionalProcessing\Config\ProcessingConfiguration;
0 ignored issues
show
Bug introduced by
The type App\Services\AdditionalP...ProcessingConfiguration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use App\Services\AdditionalProcessing\ConsoleOutputService;
9
use App\Services\AdditionalProcessing\MediaExtractionService;
10
use App\Services\AdditionalProcessing\NzbContentParser;
11
use App\Services\AdditionalProcessing\ReleaseFileManager;
12
use App\Services\AdditionalProcessing\UsenetDownloadService;
13
use App\Services\Categorization\CategorizationService;
14
use App\Services\TempWorkspaceService;
15
use Blacklight\NameFixer;
16
use Blacklight\Nfo;
17
use Blacklight\NZB;
18
use Blacklight\ReleaseExtra;
19
use Blacklight\ReleaseImage;
20
use Illuminate\Support\ServiceProvider;
21
22
/**
23
 * Service provider for Additional Processing services.
24
 * Registers all the refactored processing services with proper dependency injection.
25
 */
26
class AdditionalProcessingServiceProvider extends ServiceProvider
27
{
28
    /**
29
     * Register services.
30
     */
31
    public function register(): void
32
    {
33
        // Configuration is a singleton since it loads settings once
34
        $this->app->singleton(ProcessingConfiguration::class, function () {
35
            return new ProcessingConfiguration();
36
        });
37
38
        // Console output service
39
        $this->app->singleton(ConsoleOutputService::class, function ($app) {
40
            $config = $app->make(ProcessingConfiguration::class);
41
            return new ConsoleOutputService($config->echoCLI);
42
        });
43
44
        // NZB content parser
45
        $this->app->singleton(NzbContentParser::class, function ($app) {
46
            $config = $app->make(ProcessingConfiguration::class);
47
            return new NzbContentParser(
48
                new NZB(),
49
                $config->debugMode,
50
                $config->echoCLI
51
            );
52
        });
53
54
        // Archive extraction service
55
        $this->app->singleton(ArchiveExtractionService::class, function ($app) {
56
            return new ArchiveExtractionService(
57
                $app->make(ProcessingConfiguration::class)
58
            );
59
        });
60
61
        // Usenet download service
62
        $this->app->singleton(UsenetDownloadService::class, function ($app) {
63
            return new UsenetDownloadService(
64
                $app->make(ProcessingConfiguration::class)
65
            );
66
        });
67
68
        // Release file manager
69
        $this->app->singleton(ReleaseFileManager::class, function ($app) {
70
            return new ReleaseFileManager(
71
                $app->make(ProcessingConfiguration::class),
72
                new ReleaseExtra(),
73
                new ReleaseImage(),
74
                new Nfo(),
75
                new NZB(),
76
                new NameFixer()
77
            );
78
        });
79
80
        // Media extraction service
81
        $this->app->singleton(MediaExtractionService::class, function ($app) {
82
            return new MediaExtractionService(
83
                $app->make(ProcessingConfiguration::class),
84
                new ReleaseImage(),
85
                new ReleaseExtra(),
86
                new CategorizationService()
87
            );
88
        });
89
90
        // Temp workspace service (might already be registered elsewhere)
91
        $this->app->singleton(TempWorkspaceService::class, function () {
92
            return new TempWorkspaceService();
93
        });
94
95
        // Main orchestrator
96
        $this->app->singleton(AdditionalProcessingOrchestrator::class, function ($app) {
97
            return new AdditionalProcessingOrchestrator(
98
                $app->make(ProcessingConfiguration::class),
99
                $app->make(NzbContentParser::class),
100
                $app->make(ArchiveExtractionService::class),
101
                $app->make(MediaExtractionService::class),
102
                $app->make(UsenetDownloadService::class),
103
                $app->make(ReleaseFileManager::class),
104
                $app->make(TempWorkspaceService::class),
105
                $app->make(ConsoleOutputService::class)
106
            );
107
        });
108
    }
109
110
    /**
111
     * Bootstrap services.
112
     */
113
    public function boot(): void
114
    {
115
        //
116
    }
117
}
118
119