Passed
Pull Request — master (#39)
by Markus
07:48
created

ServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 40
ccs 16
cts 18
cp 0.8889
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setupConfig() 0 11 4
A boot() 0 3 1
A register() 0 9 1
1
<?php
2
3
namespace Butler\Graphql;
4
5
use Illuminate\Foundation\Application as LaravelApplication;
6
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
7
use Laravel\Lumen\Application as LumenApplication;
0 ignored issues
show
Bug introduced by
The type Laravel\Lumen\Application was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use React\EventLoop\Factory as ReactEventLoopFactory;
9
10
class ServiceProvider extends BaseServiceProvider
11
{
12
    /**
13
     * Register the service provider.
14
     *
15
     * @return void
16
     */
17 34
    public function register()
18
    {
19 34
        $this->app->bind(
20 34
            \GraphQL\Executor\Promise\PromiseAdapter::class,
21 34
            \GraphQL\Executor\Promise\Adapter\ReactPromiseAdapter::class
22
        );
23
24 34
        $this->app->bind(\React\EventLoop\LoopInterface::class, function () {
25 24
            return ReactEventLoopFactory::create();
26 34
        });
27 34
    }
28
29
    /**
30
     * Boot the service provider.
31
     *
32
     * @return void
33
     */
34 34
    public function boot()
35
    {
36 34
        $this->setupConfig($this->app);
37 34
    }
38
39 34
    private function setupConfig($app)
40
    {
41 34
        $source = realpath(__DIR__ . '/../config/butler.php');
42
43 34
        if ($app instanceof LaravelApplication && $app->runningInConsole()) {
44 34
            $this->publishes([$source => config_path('butler.php')]);
45
        } elseif ($app instanceof LumenApplication) {
46
            $app->configure('butler');
47
        }
48
49 34
        $this->mergeConfigFrom($source, 'butler');
50 34
    }
51
}
52