Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

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.
Passed
Push — master ( 244c2c...6b982b )
by
unknown
03:42
created

OptimizeCommand   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 35
c 1
b 0
f 0
dl 0
loc 74
rs 10
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 22 1
B execute() 0 29 7
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Command;
14
15
use Kitodo\Dlf\Common\Solr\Solr;
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Input\InputOption;
19
use Symfony\Component\Console\Output\OutputInterface;
20
use Symfony\Component\Console\Style\SymfonyStyle;
21
22
/**
23
 * CLI Command for sending the commit and/or optimize command to the index.
24
 *
25
 * @package TYPO3
26
 * @subpackage dlf
27
 *
28
 * @access public
29
 */
30
class OptimizeCommand extends Command
31
{
32
33
    /**
34
     * Configure the command by defining the name, options and arguments
35
     *
36
     * @access public
37
     *
38
     * @return void
39
     */
40
    public function configure(): void
41
    {
42
        $this
43
            ->setDescription('Sending the commit and/or optimize command to the index.')
44
            ->setHelp('')
45
            ->addOption(
46
                'solr',
47
                's',
48
                InputOption::VALUE_REQUIRED,
49
                '[UID|index_name] of the Solr core for commit and/or optimize.'
50
            )
51
            ->addOption(
52
                'commit',
53
                null,
54
                InputOption::VALUE_NONE,
55
                'If this option is set, the commit command is sent.'
56
            )
57
            ->addOption(
58
                'optimize',
59
                null,
60
                InputOption::VALUE_NONE,
61
                'If this option is set, the optimize command is sent.'
62
            );
63
    }
64
65
    /**
66
     * Executes the commit and/or optimize command.
67
     *
68
     * @access protected
69
     *
70
     * @param InputInterface $input The input parameters
71
     * @param OutputInterface $output The Symfony interface for outputs on console
72
     *
73
     * @return int
74
     */
75
    protected function execute(InputInterface $input, OutputInterface $output): int
76
    {
77
        $io = new SymfonyStyle($input, $output);
78
        $io->title($this->getDescription());
79
80
        if (empty($input->getOption('solr')) || is_array($input->getOption('solr'))) {
81
                $io->error('ERROR: Required parameter --solr|-s is missing or array.');
82
                return BaseCommand::FAILURE;
83
        }
84
85
        if (empty($input->getOption('commit')) && empty($input->getOption('optimize'))) {
86
            $io->error('ERROR: Parameter --commit or --optimize is missing.');
87
            return BaseCommand::FAILURE;
88
        }
89
90
        // Get Solr instance.
91
        $solr = Solr::getInstance($input->getOption('solr'));
92
        // Connect to Solr server.
93
        if (!$solr->ready) {
94
            $io->error('ERROR: Connection to Solr core ("' . $input->getOption('solr') . '") not possible \n');
95
            return BaseCommand::FAILURE;
96
        }
97
98
        if (!$solr->optimize($input->getOption('commit'), $input->getOption('optimize'))) {
99
            $io->error('ERROR: Optimizing the Solr core ("' . $input->getOption('solr') . '") not possible \n');
100
            return BaseCommand::FAILURE;
101
        }
102
103
        return BaseCommand::SUCCESS;
104
    }
105
}
106