private function anonymizeTable(string $table): bool
    {
        $total = $this->getTotal($table);
        if ($total === 0) {
            $this->output->writeln("<info>$table is empty</info>");

            return true;
        }

        $bar = new ProgressBar($this->output, $total);
        $bar->setRedrawFrequency($total > 100 ? 100 : 0);

        $this->output->writeln("<info>Anonymizing $table</info>");

        try {
            $queries = $this->db->setLimit($total)->processEntity(
                $table,
                function () use ($bar) {
                    $bar->advance();
                }
            );
            // @codeCoverageIgnoreStart
        } catch (\Exception $e) {
            $msg = "<error>Error anonymizing $table. Message was : " . $e->getMessage() . "</error>";
            $this->output->writeln(PHP_EOL . $msg . PHP_EOL);

            return false;
        }
        // @codeCoverageIgnoreEnd

        $this->output->writeln(PHP_EOL);

        if ($this->input->getOption('sql')) {
            $this->output->writeln('<comment>Queries:</comment>');
            $this->output->writeln(implode(PHP_EOL, $queries));
            $this->output->writeln(PHP_EOL);
        }

        return true;
    }
private function anonymizeTable(string $table): bool
    {
        $total = $this->getTotal($table);
        if ($total === 0) {
            $this->output->writeln("<info>$table is empty</info>");

            return true;
        }

        $bar = new ProgressBar($this->output, $total);
        $bar->setRedrawFrequency($total > 100 ? 100 : 0);

        $this->output->writeln("<info>Anonymizing $table</info>");

        try {
            $queries = $this->db->setLimit($total)->processEntity(
                $table,
                function () use ($bar) {
                    $bar->advance();
                }
            );
            // @codeCoverageIgnoreStart
        } catch (\Exception $e) {
            $msg = "<error>Error anonymizing $table. Message was : " . $e->getMessage() . "</error>";
            $this->output->writeln(PHP_EOL . $msg . PHP_EOL);

            return false;
        }
        // @codeCoverageIgnoreEnd

        $this->output->writeln(PHP_EOL);

        if ($this->input->getOption('sql')) {
            $this->output->writeln('<comment>Queries:</comment>');
            $this->output->writeln(implode(PHP_EOL, $queries));
            $this->output->writeln(PHP_EOL);
        }

        return true;
    }
private function anonymizeTable ( string $ table ) : bool { $ total = $ this -> getTotal ( $ table ) ; if ( $ total === 0 ) { $ this -> output -> writeln ( "<info>$table is empty</info>" ) ; return true ; } $ bar = new ProgressBar ( $ this -> output , $ total ) ; $ bar -> setRedrawFrequency ( $ total > 100 ? 100 : 0 ) ; $ this -> output -> writeln ( "<info>Anonymizing $table</info>" ) ; try { $ queries = $ this -> db -> setLimit ( $ total ) -> processEntity ( $ table , function ( ) use ( $ bar ) { $ bar -> advance ( ) ; } ) ; // @codeCoverageIgnoreStart } catch ( \ Exception $ e ) { $ msg = "<error>Error anonymizing $table. Message was : " . $ e -> getMessage ( ) . "</error>" ; $ this -> output -> writeln ( PHP_EOL . $ msg . PHP_EOL ) ; return false ; } // @codeCoverageIgnoreEnd $ this -> output -> writeln ( PHP_EOL ) ; if ( $ this -> input -> getOption ( 'sql' ) ) { $ this -> output -> writeln ( '<comment>Queries:</comment>' ) ; $ this -> output -> writeln ( implode ( PHP_EOL , $ queries ) ) ; $ this -> output -> writeln ( PHP_EOL ) ; } return true ; }
Anonymize a specific table and display info about the job

@param  string $table

@return bool
Anonymize a specific table and display info about the job