Completed
Push — master ( d2ed7d...80de42 )
by Abdelrahman
06:39
created

AuthyServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 6
dl 0
loc 44
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 21 1
A provides() 0 4 1
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Authy Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Authy Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Authy\Providers;
17
18
use Rinvex\Authy\App as AuthyApp;
19
use Rinvex\Authy\User as AuthyUser;
20
use GuzzleHttp\Client as HttpClient;
21
use Rinvex\Authy\Token as AuthyToken;
22
use Illuminate\Support\ServiceProvider;
23
24
class AuthyServiceProvider extends ServiceProvider
25
{
26
    /**
27
     * Indicates if loading of the provider is deferred.
28
     *
29
     * @var bool
30
     */
31
    protected $defer = true;
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function register()
37
    {
38
        $httpClient = new HttpClient();
39
        $key = config('services.authy.secret');
40
41
        $this->app->singleton('rinvex.authy.app', function ($app) use ($httpClient, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
            return new AuthyApp($httpClient, $key);
43
        });
44
45
        $this->app->singleton('rinvex.authy.user', function ($app) use ($httpClient, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
            return new AuthyUser($httpClient, $key);
47
        });
48
49
        $this->app->singleton('rinvex.authy.token', function ($app) use ($httpClient, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
            return new AuthyToken($httpClient, $key);
51
        });
52
53
        $this->app->alias('rinvex.authy.app', AuthyApp::class);
54
        $this->app->alias('rinvex.authy.user', AuthyUser::class);
55
        $this->app->alias('rinvex.authy.token', AuthyToken::class);
56
    }
57
58
    /**
59
     * Get the services provided by the provider.
60
     *
61
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
62
     */
63
    public function provides()
64
    {
65
        return ['rinvex.authy.app', 'rinvex.authy.user', 'rinvex.authy.token'];
66
    }
67
}
68