Test Failed
Pull Request — master (#82)
by Aaron
02:58
created

ClearInvalidRefreshTokensCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 6

Test Coverage

Coverage 95%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 2
cbo 6
dl 0
loc 50
ccs 19
cts 20
cp 0.95
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 9 1
A execute() 0 16 3
1
<?php
2
3
/*
4
 * This file is part of the GesdinetJWTRefreshTokenBundle package.
5
 *
6
 * (c) Gesdinet <http://www.gesdinet.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gesdinet\JWTRefreshTokenBundle\Command;
13
14
use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface;
15
use Symfony\Component\Console\Command\Command;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
/**
21
 * Class ClearInvalidRefreshTokensCommand.
22
 */
23
class ClearInvalidRefreshTokensCommand extends Command
24
{
25
    /**
26
     * @var RefreshTokenManagerInterface
27 4
     */
28
    private $refreshTokenManager;
29 4
30 4
    /**
31 4
     * ClearInvalidRefreshTokensCommand constructor.
32 4
     *
33 4
     * @param RefreshTokenManagerInterface $refreshTokenManager
34 4
     */
35 4
    public function __construct(RefreshTokenManagerInterface $refreshTokenManager)
36
    {
37
        $this->refreshTokenManager = $refreshTokenManager;
38
    }
39
40 1
    /**
41
     * @see Command
42 1
     */
43
    protected function configure()
44 1
    {
45 1
        $this
46 1
            ->setName('gesdinet:jwt:clear')
47
            ->setDescription('Clear invalid refresh tokens.')
48
            ->setDefinition(array(
49
                new InputArgument('datetime', InputArgument::OPTIONAL),
50 1
            ));
51 1
    }
52
53 1
    /**
54 1
     * @see Command
55 1
     */
56 1
    protected function execute(InputInterface $input, OutputInterface $output)
57
    {
58
        $datetime = $input->getArgument('datetime');
59
60
        if (null === $datetime) {
61
            $datetime = new \DateTime();
62
        } else {
63
            $datetime = new \DateTime($datetime);
64
        }
65
66
        $revokedTokens = $this->refreshTokenManager->revokeAllInvalid($datetime);
0 ignored issues
show
Unused Code introduced by
The call to RefreshTokenManagerInterface::revokeAllInvalid() has too many arguments starting with $datetime.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
67
68
        foreach ($revokedTokens as $revokedToken) {
69
            $output->writeln(sprintf('Revoke <comment>%s</comment>', $revokedToken->getRefreshToken()));
70
        }
71
    }
72
}
73