Completed
Push — master ( 38e21d...3ba18f )
by ARCANEDEV
8s
created

SocialAuthenticator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 46
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 4 1
A drivers() 0 4 1
A enabledDrivers() 0 6 1
A isSupported() 0 4 1
1
<?php namespace Arcanedev\LaravelAuth\Services;
2
use Illuminate\Support\Collection;
3
4
/**
5
 * Class     SocialAuthenticator
6
 *
7
 * @package  Arcanedev\LaravelAuth\Services
8
 * @author   ARCANEDEV <[email protected]>
9
 */
10
class SocialAuthenticator
11
{
12
    /**
13
     * Check if social authentication is enabled.
14
     *
15
     * @return bool
16
     */
17 666
    public static function isEnabled()
18
    {
19 666
        return config('laravel-auth.socialite.enabled', false);
20
    }
21
22
    /**
23
     * Get the supported drivers.
24
     *
25
     * @return \Illuminate\Support\Collection
26
     */
27 27
    public static function drivers()
28
    {
29 27
        return Collection::make(config('laravel-auth.socialite.drivers', []));
30
    }
31
32
    /**
33
     * Get the enabled drivers.
34
     *
35
     * @return \Illuminate\Support\Collection
36
     */
37
    public static function enabledDrivers()
38
    {
39 18
        return static::drivers()->filter(function ($driver) {
40 18
            return $driver['enabled'];
41 18
        });
42
    }
43
44
    /**
45
     * Check if the given driver is supported.
46
     *
47
     * @param  string  $driver
48
     *
49
     * @return bool
50
     */
51 9
    public static function isSupported($driver)
52
    {
53 9
        return static::enabledDrivers()->has($driver);
54
    }
55
}
56