VeloServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 25
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 1
A register() 0 13 2
1
<?php
2
3
namespace Earnould\LaravelVeloApi;
4
5
use Illuminate\Support\ServiceProvider;
6
use Earnould\LaravelVeloApi\Tests\Mocks\VeloClientMock;
7
8
class VeloServiceProvider extends ServiceProvider
9
{
10 15
    public function boot()
11
    {
12 15
        $this->publishes([
13 15
            __DIR__.'/../config/laravel-velo-api.php' => config_path('laravel-velo-api.php'),
14 15
        ], 'config');
15 15
    }
16
17
    /**
18
     * Register the service provider.
19
     */
20 15
    public function register()
21
    {
22 15
        $this->mergeConfigFrom(__DIR__.'/../config/laravel-velo-api.php', 'laravel-velo-api');
23
24 15
        $this->app->bind(VeloStations::class);
25
26 15
        if (app()->environment('testing')) {
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

26
        if (app()->/** @scrutinizer ignore-call */ environment('testing')) {
Loading history...
27
            $this->app->bind('velo-stations', function () {
28 7
                return new VeloStations(new VeloClientMock());
29 15
            });
30
        } else {
31
            $this->app->bind('velo-stations', function () {
32
                return new VeloStations(new VeloClient());
33
            });
34
        }
35 15
    }
36
}
37