Passed
Push — 5.0.0 ( 51b79d...976529 )
by Fèvre
06:35
created

SessionServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Providers;
6
7
use Illuminate\Support\Facades\DB;
8
use Illuminate\Support\Facades\Session;
9
use Illuminate\Support\ServiceProvider;
10
use Xetaravel\Extensions\CustomDatabaseSessionHandler;
11
use Xetaravel\Services\DeviceDetectorService;
12
13
class SessionServiceProvider extends ServiceProvider
14
{
15
    public function register(): void
16
    {
17
        Session::extend('custom_database', function ($app) {
18
            $connection = DB::connection(config('session.connection'));
19
20
            $table = config('session.table');
21
22
            $lifetime = config('session.lifetime');
23
24
            return new CustomDatabaseSessionHandler(
25
                $connection,
26
                $table,
27
                $lifetime,
28
                $app,
29
                $app->make(DeviceDetectorService::class)
30
            );
31
        });
32
    }
33
34
    /**
35
     * Bootstrap any application services.
36
     *
37
     * @return void
38
     */
39
    public function boot(): void
40
    {
41
    }
42
43
}
44