ClientServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Spinen\QuickBooks\Providers;
4
5
use Illuminate\Contracts\Foundation\Application;
6
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
7
use Spinen\QuickBooks\Client;
8
9
/**
10
 * Class ClientServiceProvider
11
 *
12
 * @package Spinen\QuickBooks
13
 */
14
class ClientServiceProvider extends LaravelServiceProvider
15
{
16
    /**
17
     * Indicates if loading of the provider is deferred.
18
     *
19
     * @var bool
20
     */
21
    protected $defer = true;
22
23
    /**
24
     * Get the services provided by the provider.
25
     *
26
     * @return array
27
     */
28
    public function provides()
29
    {
30
        return [
31
            Client::class,
32
        ];
33
    }
34
35
    /**
36
     * Register the application services.
37
     *
38
     * @return void
39
     */
40
    public function register()
41
    {
42
        $this->app->bind(Client::class, function (Application $app) {
43
            $token = ($app->auth->user()->quickBooksToken)
0 ignored issues
show
Bug introduced by
Accessing auth on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
44
                ? : $app->auth->user()
45
                              ->quickBooksToken()
46
                              ->make();
47
48
            return new Client($app->config->get('quickbooks'), $token);
0 ignored issues
show
Bug introduced by
Accessing config on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
49
        });
50
51
        $this->app->alias(Client::class, 'QuickBooks');
52
    }
53
}
54