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

SocialAuthenticator::isSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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