OpenFoodFactsServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 2
rs 10
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