StackSessionServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 12 3
A boot() 0 6 1
1
<?php
2
3
namespace Sebdesign\StackSession;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class StackSessionServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function register()
13
    {
14
        $this->app->bind('session.handlers', static function ($app) {
15
            $session = $app->make('session');
16
            $config = $session->getSessionConfig();
17
            $drivers = $config['drivers'] ?? [];
18
19
            foreach ($drivers ?: ['file'] as $driver) {
20
                yield $driver => $session->driver($driver)->getHandler();
21
            }
22
        });
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function boot()
29
    {
30
        $this->app->make('session')->extend('stack', static function ($app) {
31
            return new StackSessionHandler($app->make('session.handlers'));
32
        });
33
    }
34
}
35