| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types = 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Contains AbstractDatabaseCommon class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * PHP version 7.0+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * LICENSE: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * This file is part of Yet Another Php Eve Api Library also know as Yapeal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * which can be used to access the Eve Online API data and place it into a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * database. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Copyright (C) 2014-2016 Michael Cummings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * This program is free software: you can redistribute it and/or modify it | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * under the terms of the GNU Lesser General Public License as published by the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * Free Software Foundation, either version 3 of the License, or (at your | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * This program is distributed in the hope that it will be useful, but WITHOUT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * You should have received a copy of the GNU Lesser General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * along with this program. If not, see | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * <http://spdx.org/licenses/LGPL-3.0.html>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * You should be able to find a copy of this license in the COPYING-LESSER.md | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * file. A copy of the GNU GPL should also be available in the COPYING.md file. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * @copyright 2014-2016 Michael Cummings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * @license   http://www.gnu.org/copyleft/lesser.html GNU LGPL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * @author    Michael Cummings <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | namespace Yapeal\Console\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use Symfony\Component\Console\Command\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | use Symfony\Component\Console\Helper\ProgressBar; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | use Symfony\Component\Console\Input\InputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | use Symfony\Component\Console\Input\InputOption; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | use Symfony\Component\Console\Output\OutputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | use Yapeal\CommonToolsTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | use Yapeal\Event\YEMAwareInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | use Yapeal\Event\YEMAwareTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | use Yapeal\Exception\YapealDatabaseException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | use Yapeal\FileSystem\CommonFileHandlingTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | use Yapeal\Log\Logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | use Yapeal\Sql\SqlSubsTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  * Class AbstractDatabaseCommon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | abstract class AbstractDatabaseCommon extends Command implements YEMAwareInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     use CommonFileHandlingTrait, CommonToolsTrait, ConfigFileTrait, SqlSubsTrait, VerbosityToStrategyTrait, YEMAwareTrait; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * Sets the help message and all the common options used by the Database:* commands. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @param string $help Command help text. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     protected function addOptions(string $help) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->addConfigFileOption(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->addOption('database', 'd', InputOption::VALUE_REQUIRED, 'Name of the database.') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             ->addOption('hostName', 'o', InputOption::VALUE_REQUIRED, 'Host name for database server.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             ->addOption('password', 'p', InputOption::VALUE_REQUIRED, 'Password used to access database.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             ->addOption('platform', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                 'l', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 InputOption::VALUE_REQUIRED, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                 'Platform of database driver. Currently only "mysql" can be used.', 'mysql') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             ->addOption('port', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                 InputOption::VALUE_REQUIRED, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 'Port number for remote server. Only needed if using http connection.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             ->addOption('tablePrefix', 't', InputOption::VALUE_REQUIRED, 'Prefix for database table names.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             ->addOption('userName', 'u', InputOption::VALUE_REQUIRED, 'User name used to access database.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             ->setHelp($help); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     /** @noinspection PhpMissingParentCallCommonInspection */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * Executes the current command. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * This method is not abstract because you can use this class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * as a concrete class. In this case, instead of defining the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * execute() method, you set the code to execute by passing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * a Closure to the setCode() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * @param InputInterface  $input  An InputInterface instance | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * @param OutputInterface $output An OutputInterface instance | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * @return int|null null or 0 if everything went fine, or an error code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * @throws \DomainException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @throws \LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @throws \Yapeal\Exception\YapealException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @see    setCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     protected function execute(InputInterface $input, OutputInterface $output): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         if (!$this->hasYem()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             $this->setYem($this->getDic()['Yapeal.Event.Mediator']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $this->setLogThresholdFromVerbosity($output); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->processCliOptions($input); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $this->processSql($output); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @param string          $sqlStatements | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @param string          $fileName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @param OutputInterface $output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @throws \DomainException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * @throws \InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * @throws \LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * @throws \Symfony\Component\Console\Exception\LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * @throws \Yapeal\Exception\YapealDatabaseException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @internal param string $sqlStatements | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     protected function executeSqlStatements(string $sqlStatements, string $fileName, OutputInterface $output) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $pdo = $this->getPdo(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $yem = $this->getYem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         $statements = explode(';', $this->getCleanedUpSql($sqlStatements, $this->getReplacements())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $statements = array_filter($statements, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |             function ($statement) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                 return '' !== trim($statement); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $progress = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         if ($output::VERBOSITY_QUIET !== $output->getVerbosity()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             if (false === strpos($fileName, '::')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 $mess = sprintf('<info>Execute %1$s/%2$s</info>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                     basename(dirname($fileName)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                     basename($fileName)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                 $mess = sprintf('<info>Execute %s</info>', $fileName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             $yem->triggerLogEvent('Yapeal.Log.log', Logger::INFO, strip_tags($mess)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             $output->writeln($mess); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             $progress = $this->createProgressBar($output, count($statements)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         foreach ($statements as $statement => $sql) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                 $pdo->exec($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                 if (null !== $progress) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                     $progress->setMessage('<comment>executing</comment>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                     $progress->advance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             } catch (\PDOException $exc) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                 if (null !== $progress) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                     $progress->setMessage('<error>Failed</error>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                     $progress->finish(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                     $output->writeln(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 $mess = $sql . PHP_EOL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 $mess .= sprintf('Sql failed in %1$s on statement %2$s with (%3$s) %4$s', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                     $fileName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                     $statement, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                     $exc->getCode(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                     $exc->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 throw new YapealDatabaseException($mess, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         if (null !== $progress) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             $progress->setMessage(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |             $progress->finish(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             $output->writeln(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * @throws \LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     protected function getReplacements() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         if (null === $this->replacements) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             $this->replacements = $this->getSqlSubs($this->getDic()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         return $this->replacements; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * @param InputInterface $input | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * @return AbstractDatabaseCommon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      * @throws \DomainException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      * @throws \LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      * @throws \Yapeal\Exception\YapealException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     protected function processCliOptions(InputInterface $input) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $dic = $this->getDic(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $options = $input->getOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         if (!empty($options['configFile'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             $this->processConfigFile($options['configFile'], $dic); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         $base = 'Yapeal.Sql.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         foreach (['class', 'database', 'hostName', 'password', 'platform', 'tablePrefix', 'userName'] as $option) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             if (array_key_exists($option, $options) && null !== $options[$option]) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |                 $dic[$base . $option] = $options[$option]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      * @param OutputInterface $output | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 206 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 207 |  |  |     abstract protected function processSql(OutputInterface $output); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @var array $replacements Holds a list of Sql section replacement pairs. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     protected $replacements; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * @param OutputInterface $output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * @param int             $statementCount | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      * @return ProgressBar | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     private function createProgressBar(OutputInterface $output, int $statementCount): ProgressBar | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $progress = new ProgressBar($output); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $progress->setRedrawFrequency(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $progress->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s% %message%'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $progress->setMessage('<info>starting</info>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $progress->start($statementCount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         $progress->setBarWidth(min(4 * $statementCount + 2, 50)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         return $progress; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 228 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 229 |  |  |  | 
            
                        
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.