Issues (985)

app/Providers/SearchServiceProvider.php (2 issues)

Severity
1
<?php
2
3
namespace App\Providers;
4
5
use App\Services\Search\Contracts\SearchServiceInterface;
6
use App\Services\Search\ElasticSearchService;
7
use App\Services\Search\ManticoreSearchService;
8
use Illuminate\Support\ServiceProvider;
9
10
class SearchServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Register any application services.
14
     */
15
    public function register(): void
16
    {
17
        // Register ManticoreSearchService as singleton
18
        $this->app->singleton(ManticoreSearchService::class, function ($app) {
0 ignored issues
show
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
        $this->app->singleton(ManticoreSearchService::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
            return new ManticoreSearchService();
20
        });
21
22
        // Register ElasticSearchService as singleton
23
        $this->app->singleton(ElasticSearchService::class, function ($app) {
0 ignored issues
show
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

23
        $this->app->singleton(ElasticSearchService::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
            return new ElasticSearchService();
25
        });
26
27
        // Bind the interface to the appropriate implementation based on config
28
        $this->app->singleton(SearchServiceInterface::class, function ($app) {
29
            if (config('nntmux.elasticsearch_enabled') === true) {
30
                return $app->make(ElasticSearchService::class);
31
            }
32
33
            return $app->make(ManticoreSearchService::class);
34
        });
35
36
        // Register alias for ManticoreSearch (for backward compatibility)
37
        $this->app->alias(ManticoreSearchService::class, 'manticore');
38
    }
39
40
    /**
41
     * Bootstrap any application services.
42
     */
43
    public function boot(): void
44
    {
45
        //
46
    }
47
}
48
49