ServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 17
c 2
b 0
f 1
dl 0
loc 43
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 4
A register() 0 20 2
1
<?php
2
3
namespace Transmission\Laravel;
4
5
use Illuminate\Foundation\Application as LaravelApplication;
6
use Laravel\Lumen\Application as LumenApplication;
7
use Transmission\Client;
8
9
/**
10
 * Class ServiceProvider.
11
 */
12
class ServiceProvider extends \Illuminate\Support\ServiceProvider
13
{
14
    /**
15
     * Boot the Service Provider.
16
     *
17
     * @return void
18
     */
19
    public function boot()
20
    {
21
        if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
22
            $this->publishes([
23
                __DIR__.'/config/transmission.php' => config_path('transmission.php'),
24
            ]);
25
        } elseif ($this->app instanceof LumenApplication) {
26
            $this->app->configure('transmission');
0 ignored issues
show
Bug introduced by
The method configure() does not exist on Illuminate\Contracts\Foundation\Application. Did you maybe mean configPath()? ( Ignorable by Annotation )

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

26
            $this->app->/** @scrutinizer ignore-call */ 
27
                        configure('transmission');

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...
27
        }
28
    }
29
30
    /**
31
     * Register the Service.
32
     *
33
     * @return void
34
     */
35
    public function register()
36
    {
37
        $this->mergeConfigFrom(__DIR__.'/config/transmission.php', 'transmission');
38
39
        $this->app->singleton('transmission', function () {
40
            $client = new Client(
41
                config('transmission.host'),
42
                config('transmission.port'),
43
                config('transmission.username'),
44
                config('transmission.password')
45
            );
46
47
            if (config('transmission.enableTLS')) {
48
                $client = $client->enableTLS();
49
            }
50
51
            return $client;
52
        });
53
54
        $this->app->alias('transmission', Client::class);
55
    }
56
}
57