SessionDependencyProvider::getSessionHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Xervice\Session;
5
6
7
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
8
use Xervice\Core\Business\Model\Dependency\DependencyContainerInterface;
9
use Xervice\Core\Business\Model\Dependency\Provider\AbstractDependencyProvider;
10
11
class SessionDependencyProvider extends AbstractDependencyProvider
12
{
13
    public const SESSION_HANDLER = 'session.handler';
14
15
    /**
16
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
17
     *
18
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
19
     */
20 1
    public function handleDependencies(DependencyContainerInterface $container): DependencyContainerInterface
21
    {
22 1
        $container = $this->addSessionHandler($container);
23
24 1
        return $container;
25
    }
26
27
    /**
28
     * @return \SessionHandlerInterface
29
     * @throws \RuntimeException
30
     * @throws \InvalidArgumentException
31
     */
32 1
    protected function getSessionHandler(DependencyContainerInterface $container): \SessionHandlerInterface
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
    protected function getSessionHandler(/** @scrutinizer ignore-unused */ DependencyContainerInterface $container): \SessionHandlerInterface

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34 1
        return new NativeFileSessionHandler();
35
    }
36
37
    /**
38
     * @param \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface $container
39
     *
40
     * @return \Xervice\Core\Business\Model\Dependency\DependencyContainerInterface
41
     */
42 1
    protected function addSessionHandler(
43
        DependencyContainerInterface $container
44
    ): DependencyContainerInterface {
45
        $container[self::SESSION_HANDLER] = function (DependencyContainerInterface $container) {
46 1
            return $this->getSessionHandler($container);
47
        };
48 1
        return $container;
49
    }
50
51
}