PolicyMakeCommand::replaceUserNamespace()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
rs 9.8666
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Console\Commands;
6
7
use Illuminate\Console\ConfirmableTrait;
8
use Cortex\Foundation\Traits\ConsoleMakeModuleCommand;
9
use Illuminate\Foundation\Console\PolicyMakeCommand as BasePolicyMakeCommand;
10
11
class PolicyMakeCommand extends BasePolicyMakeCommand
12
{
13
    use ConfirmableTrait;
14
    use ConsoleMakeModuleCommand;
15
16
    /**
17
     * Replace the User model namespace.
18
     *
19
     * @param string $stub
20
     *
21
     * @return string
22
     */
23
    protected function replaceUserNamespace($stub): string
24
    {
25
        if (! $userModel = config('auth.providers.'.config('auth.guards.'.config('auth.defaults.guard').'.provider').'.model')) {
26
            return $stub;
27
        }
28
29
        return str_replace(
30
            $this->rootNamespace().'User',
31
            $userModel,
32
            $stub
33
        );
34
    }
35
}
36