PassportContainerConfigurator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 30
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A configureContainer() 0 19 1
1
<?php declare(strict_types=1);
2
3
namespace Limoncello\Passport\Package;
4
5
/**
6
 * Copyright 2015-2019 [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 Doctrine\DBAL\Connection;
22
use Limoncello\Contracts\Application\ContainerConfiguratorInterface;
23
use Limoncello\Contracts\Container\ContainerInterface as LimoncelloContainerInterface;
24
use Limoncello\Passport\Adaptors\Generic\PassportServerIntegration;
25
use Limoncello\Passport\Adaptors\Generic\TokenRepository;
26
use Limoncello\Passport\Contracts\Entities\DatabaseSchemaInterface;
27
use Limoncello\Passport\Contracts\PassportServerIntegrationInterface;
28
use Limoncello\Passport\Contracts\Repositories\TokenRepositoryInterface;
29
use Psr\Container\ContainerInterface as PsrContainerInterface;
30
31
/**
32
 * @package Limoncello\Passport
33
 */
34
class PassportContainerConfigurator extends BasePassportContainerConfigurator implements ContainerConfiguratorInterface
35
{
36
    /** @var callable */
37
    const CONFIGURATOR = [self::class, self::CONTAINER_METHOD_NAME];
38
39
    /**
40
     * @inheritdoc
41
     *
42
     * @SuppressWarnings(PHPMD.UnusedLocalVariable)
43
     */
44 1
    public static function configureContainer(LimoncelloContainerInterface $container): void
45
    {
46 1
        static::baseConfigureContainer($container);
0 ignored issues
show
Unused Code introduced by
The call to the method Limoncello\Passport\Pack...aseConfigureContainer() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
47
48
        $container[PassportServerIntegrationInterface::class] = function (
49
            PsrContainerInterface $container
50
        ): PassportServerIntegrationInterface {
51 1
            return new PassportServerIntegration($container);
52
        };
53
54
        $container[TokenRepositoryInterface::class] = function (
55
            PsrContainerInterface $container
56
        ): TokenRepositoryInterface {
57 1
            $connection = $container->get(Connection::class);
58 1
            $schema     = $container->get(DatabaseSchemaInterface::class);
59
60 1
            return new TokenRepository($connection, $schema);
61
        };
62
    }
63
}
64