VeloServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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