Code Duplication    Length = 15-15 lines in 2 locations

src/helpers.php 2 locations

@@ 5-19 (lines=15) @@
2
3
use Illuminate\Contracts\Auth\Authenticatable;
4
5
if (! function_exists('can_impersonate')) {
6
7
	/**
8
	 * Check whether the current user is authorized to impersonate.
9
	 *
10
	 * @param  null  $guard
11
	 * @return bool
12
	 */
13
	function can_impersonate(string $guard = null): bool
14
	{
15
		$guard = $guard ?? app('impersonate')->getCurrentAuthGuardName();
16
17
		return app('auth')->guard($guard)->check() && app('auth')->guard($guard)->canImpersonate();
18
	}
19
}
20
21
if (! function_exists('can_be_impersonated')) {
22
@@ 40-54 (lines=15) @@
37
	}
38
}
39
40
if (! function_exists('is_impersonating')) {
41
42
	/**
43
	 * Check whether the current user is being impersonated.
44
	 *
45
	 * @param  string|null  $guard
46
	 * @return bool
47
	 */
48
	function is_impersonating(string $guard = null): bool
49
	{
50
		$guard = $guard ?? app('impersonate')->getCurrentAuthGuardName();
51
52
		return app('auth')->guard($guard)->check() && app('auth')->guard($guard)->user()->isImpersonated();
53
	}
54
}
55