ServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 15
c 2
b 0
f 1
dl 0
loc 46
ccs 20
cts 20
cp 1
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 3
A provides() 0 3 1
A boot() 0 9 2
1
<?php
2
3
namespace MyriadSoap;
4
5
use Illuminate\Contracts\Support\DeferrableProvider;
6
7
class ServiceProvider extends \Illuminate\Support\ServiceProvider implements DeferrableProvider
8
{
9 28
    public function boot()
10
    {
11 28
        if ($this->app->runningInConsole()) {
12 28
            $this->publishes([
13 28
                __DIR__ . '/../config/myriad-soap.php' => config_path('myriad-soap.php'),
14 28
            ], 'config');
15
16
17 28
            $this->commands([]);
18
        }
19
    }
20
21
    /**
22
     * Register the service provider.
23
     *
24
     * @return void
25
     */
26 28
    public function register()
27
    {
28 28
        $this->mergeConfigFrom(__DIR__ . '/../config/myriad-soap.php', 'myriad-soap');
29
30 28
        $this->app->singleton('myriad_soap', function ($app) {
31 27
            $options = $app['config']['myriad-soap']['options'] ?? [];
32
33 27
            if (!empty($app['config']['myriad-soap']['use_http_version_1']) && !isset($options['stream_context'])) {
34 27
                $options['stream_context'] = stream_context_create(
35 27
                    [ 'http' => [ 'protocol_version' => 1.0 ] ]
36 27
                );
37
            }
38
39 27
            return new MyriadApi(
40 27
                new MyriadSoapClient(null, $options)
41 27
            );
42 28
        });
43
    }
44
45
    /**
46
     * Get the services provided by the provider.
47
     *
48
     * @return array
49
     */
50 2
    public function provides()
51
    {
52 2
        return [ 'myriad_soap' ];
53
    }
54
}
55