OpenFoodFactsServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 2
A register() 0 8 1
1
<?php
2
3
namespace OpenFoodFacts\Laravel;
4
5
use Illuminate\Contracts\Container\Container;
6
use Illuminate\Support\ServiceProvider;
7
8
class OpenFoodFactsServiceProvider extends ServiceProvider
9
{
10 30
    public function boot(): void
11
    {
12 30
        if ($this->app->runningInConsole()) {
13 30
            $this->publishes([
14 30
                __DIR__.'/../config/openfoodfacts.php' => config_path('openfoodfacts.php'),
15 30
            ], 'config');
16
        }
17
    }
18
19
    /**
20
     * @inheritDoc
21
     */
22 30
    public function register()
23
    {
24 30
        $this->mergeConfigFrom(__DIR__.'/../config/openfoodfacts.php', 'openfoodfacts');
25
26
        // Bindings for each environment
27 30
        $this->app->singleton('openfoodfacts', fn (Container $app) => new OpenFoodFacts($app, environment: 'food'));
28 30
        $this->app->singleton('openbeautyfacts', fn (Container $app) => new OpenFoodFacts($app, environment: 'beauty'));
29 30
        $this->app->singleton('openpetfoodfacts', fn (Container $app) => new OpenFoodFacts($app, environment: 'pet'));
30
    }
31
}
32