DumpServerServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 16
c 4
b 0
f 0
dl 0
loc 43
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 7 2
A register() 0 21 1
1
<?php
2
3
namespace BeyondCode\DumpServer;
4
5
use Illuminate\Support\ServiceProvider;
6
use Symfony\Component\VarDumper\VarDumper;
7
use Symfony\Component\VarDumper\Server\Connection;
8
use Symfony\Component\VarDumper\Server\DumpServer;
9
use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
10
11
class DumpServerServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     *
16
     * @return void
17
     */
18
    public function boot()
19
    {
20
        if ($this->app->runningInConsole()) {
21
22
            $this->publishes([
23
                __DIR__.'/../config/config.php' => config_path('debug-server.php'),
24
            ], 'config');
25
        }
26
    }
27
28
    /**
29
     * Register the application services.
30
     *
31
     * @return void
32
     */
33
    public function register()
34
    {
35
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'debug-server');
36
37
        $this->app->bind('command.dumpserver', DumpServerCommand::class);
38
39
        $this->commands([
40
            'command.dumpserver',
41
        ]);
42
43
        $host = $this->app['config']->get('debug-server.host');
44
45
        $this->app->when(DumpServer::class)->needs('$host')->give($host);
46
47
        $connection = new Connection($host, [
48
            'request' => new RequestContextProvider($this->app['request']),
49
            'source' => new SourceContextProvider('utf-8', base_path()),
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

49
            'source' => new SourceContextProvider('utf-8', /** @scrutinizer ignore-call */ base_path()),
Loading history...
50
        ]);
51
52
        VarDumper::setHandler(function ($var) use ($connection) {
53
            $this->app->makeWith(Dumper::class, ['connection' => $connection])->dump($var);
0 ignored issues
show
Bug introduced by
The method makeWith() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

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

53
            $this->app->/** @scrutinizer ignore-call */ 
54
                        makeWith(Dumper::class, ['connection' => $connection])->dump($var);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
        });
55
    }
56
}
57