From e52dc94c77081e43204b8dcb9f8791aafd536f29 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Mon, 12 Dec 2016 20:44:36 +0300 Subject: [PATCH] ImportUsersCommand code quality fix. --- .../Command/ImportUsersCommand.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Skobkin/Bundle/PointToolsBundle/Command/ImportUsersCommand.php b/src/Skobkin/Bundle/PointToolsBundle/Command/ImportUsersCommand.php index 46912b1..b349904 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Command/ImportUsersCommand.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Command/ImportUsersCommand.php @@ -12,7 +12,12 @@ use Symfony\Component\Filesystem\Filesystem; /** * Import users from CSV file exported from database by query: - * COPY (SELECT u.id, u.login, ui.name, to_char(ui.created, 'YYYY-MM-DD_HH24:MI:SS') AS created_at FROM users.logins u LEFT JOIN users.info ui ON (ui.id = u.id) WHERE u.id <> (-1)) TO '/tmp/point_users.csv' WITH HEADER DELIMITER '|' CSV; + * COPY ( + * SELECT u.id, u.login, ui.name, to_char(ui.created, 'YYYY-MM-DD_HH24:MI:SS') AS created_at + * FROM users.logins u + * LEFT JOIN users.info ui ON (ui.id = u.id) + * WHERE u.id <> (-1) + * ) TO '/tmp/point_users.csv' WITH HEADER DELIMITER '|' CSV; */ class ImportUsersCommand extends ContainerAwareCommand { @@ -50,17 +55,17 @@ class ImportUsersCommand extends ContainerAwareCommand if (!($fs->exists($fileName) && is_readable($fileName))) { $output->writeln('File does not exists or not readable.'); - return false; + return 1; } if (false === ($file = fopen($fileName, 'r'))) { $output->writeln('fopen() error'); - return false; + return 1; } if (!$input->getOption('no-skip-first')) { // Reading headers line - $test = fgets($file); + fgets($file); } $count = 0; @@ -90,7 +95,7 @@ class ImportUsersCommand extends ContainerAwareCommand $em->detach($user); } - if ($output->isVerbose()) { + if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) { $output->writeln('@' . $row[1] . ' added'); }