Passed
Push — develop ( 7600ed...503338 )
by Enea
04:04
created

Helper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 11
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorizer() 0 3 1
A authenticated() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author enea dhack <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Enea\Authorization\Support;
13
14
use Enea\Authorization\Authorizer;
15
use Enea\Authorization\Contracts\Authorizable;
16
17
class Helper
18
{
19 5
    public function authenticated(?string $guard = null): ?Authorizable
20
    {
21 5
        $authenticated = auth($guard)->user();
22 5
        return $authenticated instanceof Authorizable ? $authenticated : null;
23
    }
24
25 1
    public function authorizer(): Authorizer
26
    {
27 1
        return app()->make(Authorizer::class);
28
    }
29
}
30