GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ReleaseLockCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 21
c 1
b 0
f 0
dl 0
loc 39
ccs 22
cts 22
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 16 1
A execute() 0 11 1
1
<?php declare(strict_types=1);
2
3
namespace Gruberro\MongoDbMigrations\Console\Command;
4
5
use Gruberro\MongoDbMigrations;
6
use MongoDB\Client;
7
use Symfony\Component\Console;
8
9
class ReleaseLockCommand extends Console\Command\Command
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 2
    protected function configure()
15
    {
16
        $this
17 2
            ->setName('php-mongodb-migrations:release-lock')
18 2
            ->setDescription('Release current migration lock')
19 2
            ->addOption(
20 2
                'server',
21 2
                's',
22 2
                Console\Input\InputOption::VALUE_REQUIRED,
23 2
                'The connection string (e.g. mongodb://[username:password@]host1[:port1][,host2[:port2:],...]/db)',
24 2
                'mongodb://localhost:27017'
25
            )
26 2
            ->addArgument(
27 2
                'database',
28 2
                Console\Input\InputArgument::REQUIRED,
29 2
                'The database to connect to'
30
            )
31
        ;
32 2
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
38
    {
39 2
        $client = new Client($input->getOption('server'));
0 ignored issues
show
Bug introduced by
It seems like $input->getOption('server') can also be of type string[]; however, parameter $uri of MongoDB\Client::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
        $client = new Client(/** @scrutinizer ignore-type */ $input->getOption('server'));
Loading history...
40 2
        $db = $client->selectDatabase($input->getArgument('database'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('database') can also be of type string[]; however, parameter $databaseName of MongoDB\Client::selectDatabase() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        $db = $client->selectDatabase(/** @scrutinizer ignore-type */ $input->getArgument('database'));
Loading history...
41 2
        $output->writeln("<info>✓ Successfully established database connection</info>", $output::VERBOSITY_VERBOSE);
42
43 2
        $databaseMigrationsLockCollection = $db->selectCollection('DATABASE_MIGRATIONS_LOCK');
44 2
        $databaseMigrationsLockCollection->updateOne(['locked' => ['$exists' => true]], ['$set' => ['locked' => false]], ['upsert' => true]);
45 2
        $output->writeln("<info>✓ Successfully released migration lock</info>");
46
47 2
        return 0;
48
    }
49
}
50