OpenFoodFactsServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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