Passed
Push — master ( 4393f1...8816bb )
by Ashish
02:47
created

determineTwoFAModel()   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\Database\Eloquent\Model;
6
use Illuminate\Support\ServiceProvider;
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
    /**
39
     * Get User moded defined in config file.
40
     *
41
     * @return string
42
     */
43
    public static function determineTwoFAModel(): string
44
    {
45
        return config('2fa-config.model');
46
    }
47
48
    /**
49
     * Get User Model Instance.
50
     *
51
     * @return \Illuminate\Database\Eloquent\Model
52
     */
53
    public static function getTwoFAModelInstance(): Model
54
    {
55
        $TwoFAModelClassName = self::determineTwoFAModel();
56
57
        return new $TwoFAModelClassName();
58
    }
59
}
60