Test Failed
Push — master ( 06feab...820423 )
by Ashish
02:16
created

determineUserModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Thecodework\TwoFactorAuthentication;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Database\Eloquent\Model;
7
8
class TwoFactorAuthenticationServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Perform post-registration booting of services.
12
     * Loading Routes, Views and Migrations.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->loadRoutesFrom(__DIR__ . '/routes/routes.php');
19
        $this->loadViewsFrom(__DIR__ . '/../resources/views', '2fa');
20
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
21
22
        // Publishing configuration file
23
        $this->publishes([
24
            __DIR__ . '/../config/2fa-config.php' => config_path('2fa-config.php'),
25
        ], 'config');
26
27
        // Publishing migration
28
        $this->publishes([
29
            __DIR__ . '/../database/migrations/' => database_path('migrations'),
30
        ], 'migrations');
31
32
        // Publishing views
33
        $this->publishes([
34
            __DIR__ . '/../resources/views/' => resource_path('views/vendor/2fa'),
35
        ], 'views');
36
    }
37
38
    public static function determineUserModel(): string
39
    {
40
        return $userModel = config('2fa-config.model');
0 ignored issues
show
Unused Code introduced by
$userModel is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
41
    }
42
43
    public static function getUserModelInstance(): Model {
44
        $userModelClassName = self::determineUserModel();
45
        return new $userModelClassName();
46
    }
47
}
48