RemoveExpiredFilesCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Azine\JsCryptoStoreBundle\Command;
4
5
use Azine\JsCryptoStoreBundle\Entity\EncryptedFile;
6
use Azine\JsCryptoStoreBundle\Entity\Repositories\EncryptedFileRepository;
7
use Monolog\Logger;
8
use Symfony\Bridge\Doctrine\ManagerRegistry;
0 ignored issues
show
Bug introduced by
The type Symfony\Bridge\Doctrine\ManagerRegistry was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
/**
14
 * Remove all encrypted file that are expired from the database.
15
 *
16
 * @author dominik
17
 */
18
class RemoveExpiredFilesCommand extends Command
19
{
20
    /**
21
     * @var string|null The default command name
22
     */
23
    protected static $defaultName = 'js-crypto-store:remove-expired';
24
25
    /** @var ManagerRegistry */
26
    private $managerRegistry;
27
28
    public function __construct(ManagerRegistry $managerRegistry, Logger $logger)
0 ignored issues
show
Unused Code introduced by
The parameter $logger 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

28
    public function __construct(ManagerRegistry $managerRegistry, /** @scrutinizer ignore-unused */ Logger $logger)

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...
29
    {
30
        parent::__construct();
31
        $this->managerRegistry = $managerRegistry;
32
    }
33
34
    protected function configure()
35
    {
36
        $this->setName(self::$defaultName)
37
            ->setDescription('Remove all encrypted file that are expired from the database')
38
            ->setHelp(<<<EOF
39
The <info>js-crypto-store:remove-expired</info> command removes all expired files from the database.
40
EOF
41
            )
42
            ;
43
    }
44
45
    protected function execute(InputInterface $input, OutputInterface $output)
46
    {
47
        /** @var EncryptedFileRepository $repository */
48
        $repository = $this->managerRegistry->getRepository(EncryptedFile::class);
49
        $repository->removeExpiredFiles();
50
    }
51
}
52