Completed
Push — develop ( ea9a36...1bc5bd )
by Neomerx
05:01
created

SessionContainerConfigurator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
wmc 1
lcom 0
cbo 3
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A configureContainer() 0 16 1
1
<?php namespace Limoncello\Application\Packages\Session;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Application\Contracts\Session\SessionFunctionsInterface;
20
use Limoncello\Application\Session\Session;
21
use Limoncello\Application\Session\SessionFunctions;
22
use Limoncello\Contracts\Application\ContainerConfiguratorInterface;
23
use Limoncello\Contracts\Container\ContainerInterface as LimoncelloContainerInterface;
24
use Limoncello\Contracts\Session\SessionInterface;
25
use Psr\Container\ContainerInterface as PsrContainerInterface;
26
27
/**
28
 * @package Limoncello\Application
29
 */
30
class SessionContainerConfigurator implements ContainerConfiguratorInterface
31
{
32
    /**
33
     * @inheritdoc
34
     */
35
    public static function configureContainer(LimoncelloContainerInterface $container): void
36
    {
37
        $container[SessionInterface::class] = function (PsrContainerInterface $container): SessionInterface {
38
            /** @var SessionFunctionsInterface $functions */
39
            $functions = $container->get(SessionFunctionsInterface::class);
40
            $session   = new Session($functions);
41
42
            return $session;
43
        };
44
45
        $container[SessionFunctionsInterface::class] = function (): SessionFunctionsInterface {
46
            $functions = new SessionFunctions();
47
48
            return $functions;
49
        };
50
    }
51
}
52