From e07e9c5b8ead08570ae7bf2a2935cf3ed42808c9 Mon Sep 17 00:00:00 2001 From: LautaroCesso Date: Fri, 18 Feb 2022 18:30:49 -0300 Subject: [PATCH] [DEV-239] Prettify code --- server/controllers/system/csv-import.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/server/controllers/system/csv-import.php b/server/controllers/system/csv-import.php index 68ddb7b4..ffbe6564 100755 --- a/server/controllers/system/csv-import.php +++ b/server/controllers/system/csv-import.php @@ -42,13 +42,7 @@ class CSVImportController extends Controller { $file = fopen($fileUploader->getFullFilePath(),'r'); $errors = []; - $user = fgetcsv($file); - - while($user != null) { - if($user == false) { - throw new RequestException("Error trying to read file"); - } - + while(($user = fgetcsv($file)) != false) { Controller::setDataRequester(function ($key) use ($user) { switch ($key) { case 'email': @@ -70,8 +64,6 @@ class CSVImportController extends Controller { } catch (\Exception $exception) { $errors[] = $exception->getMessage() . ' in email ' . $user[0]; } - - $user = fgetcsv($file); } fclose($file); @@ -80,4 +72,4 @@ class CSVImportController extends Controller { Response::respondSuccess($errors); } -} \ No newline at end of file +}