CookieContainerConfigurator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A configureContainer() 0 20 1
1
<?php declare(strict_types=1);
2
3
namespace Limoncello\Application\Packages\Cookies;
4
5
/**
6
 * Copyright 2015-2020 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Limoncello\Application\Contracts\Cookie\CookieFunctionsInterface;
22
use Limoncello\Application\Cookies\CookieFunctions;
23
use Limoncello\Application\Cookies\CookieJar;
24
use Limoncello\Contracts\Application\ContainerConfiguratorInterface;
25
use Limoncello\Contracts\Container\ContainerInterface as LimoncelloContainerInterface;
26
use Limoncello\Contracts\Cookies\CookieJarInterface;
27
use Limoncello\Contracts\Settings\SettingsProviderInterface;
28
use Psr\Container\ContainerInterface as PsrContainerInterface;
29
30
/**
31
 * @package Limoncello\Application
32
 */
33
class CookieContainerConfigurator implements ContainerConfiguratorInterface
34
{
35
    /** @var callable */
36
    const CONFIGURATOR = [self::class, self::CONTAINER_METHOD_NAME];
37
38
    /**
39
     * @inheritdoc
40
     *
41 1
     * @SuppressWarnings(PHPMD.StaticAccess)
42
     */
43 1
    public static function configureContainer(LimoncelloContainerInterface $container): void
44
    {
45 1
        $container[CookieJarInterface::class] =
46
            function (PsrContainerInterface $container): CookieJarInterface {
47 1
                $settings = $container->get(SettingsProviderInterface::class)->get(CookieSettings::class);
48 1
49 1
                return new CookieJar(
50 1
                    $settings[CookieSettings::KEY_DEFAULT_PATH],
51 1
                    $settings[CookieSettings::KEY_DEFAULT_DOMAIN],
52 1
                    $settings[CookieSettings::KEY_DEFAULT_IS_SEND_ONLY_OVER_SECURE_CONNECTION],
53
                    $settings[CookieSettings::KEY_DEFAULT_IS_ACCESSIBLE_ONLY_THROUGH_HTTP],
54
                    $settings[CookieSettings::KEY_DEFAULT_IS_RAW]
55
                );
56 1
            };
57
58 1
        $container[CookieFunctionsInterface::class] =
59
            function (PsrContainerInterface $container): CookieFunctionsInterface {
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

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

Loading history...
60
                return new CookieFunctions();
61
            };
62
    }
63
}
64