Passed
Push — trunk ( 9cbbee...215be7 )
by Christian
13:52 queued 12s
created

SystemIsInstalledCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 14 2
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Maintenance\System\Command;
4
5
use Doctrine\DBAL\Connection;
6
use Shopware\Core\Framework\Log\Package;
7
use Symfony\Component\Console\Attribute\AsCommand;
8
use Symfony\Component\Console\Command\Command;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Command\Command 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\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Console\Style\SymfonyStyle;
12
13
/**
14
 * This command can be used to detect if the system is installed to script a Shopware installation or update.
15
 */
16
#[Package('core')]
17
#[AsCommand(
18
    name: 'system:is-installed',
19
    description: 'Checks if the system is installed and returns exit code 0 if Shopware is installed',
20
)]
21
class SystemIsInstalledCommand extends Command
22
{
23
    /**
24
     * @internal
25
     */
26
    public function __construct(private readonly Connection $connection)
27
    {
28
        parent::__construct();
29
    }
30
31
    protected function execute(InputInterface $input, OutputInterface $output): int
32
    {
33
        $io = new SymfonyStyle($input, $output);
34
35
        try {
36
            $this->connection->fetchAllAssociative('SHOW COLUMNS FROM migration');
37
38
            $io->success('Shopware is installed');
39
40
            return self::SUCCESS;
41
        } catch (\Exception) {
42
            $io->error('Shopware is not installed');
43
44
            return self::FAILURE;
45
        }
46
    }
47
}
48