Passed
Pull Request — master (#22)
by Mostafa Abd El-Salam
03:56
created

Helpers::getModelForGuard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Maklad\Permission;
4
5
class Helpers
6
{
7
    /**
8
     * @param string $guard
9
     *
10
     * @return string|null
11
     */
12 2
    public static function getModelForGuard(string $guard)
13
    {
14 2
        return collect(config('auth.guards'))
15 2
            ->map(function ($guard) {
16 2
                return config("auth.providers.{$guard['provider']}.model");
17 2
            })->get($guard);
18
    }
19
20
    /**
21
     * Log Alert Message
22
     * @param string $message
23
     *
24
     * @return string
25
     */
26
    public static function logAlertMessage(string $message):string
27
    {
28
        if (config('permission.log_registration_exception')) {
29
            $logger = app('log');
30
            $logger->alert($message);
31
        }
32
33
        return $message;
34
    }
35
}
36