[DEV-239] Prettify code

This commit is contained in:
LautaroCesso 2022-02-18 18:30:49 -03:00
parent 7996c933c6
commit e07e9c5b8e
1 changed files with 2 additions and 10 deletions

View File

@ -42,13 +42,7 @@ class CSVImportController extends Controller {
$file = fopen($fileUploader->getFullFilePath(),'r'); $file = fopen($fileUploader->getFullFilePath(),'r');
$errors = []; $errors = [];
$user = fgetcsv($file); while(($user = fgetcsv($file)) != false) {
while($user != null) {
if($user == false) {
throw new RequestException("Error trying to read file");
}
Controller::setDataRequester(function ($key) use ($user) { Controller::setDataRequester(function ($key) use ($user) {
switch ($key) { switch ($key) {
case 'email': case 'email':
@ -70,8 +64,6 @@ class CSVImportController extends Controller {
} catch (\Exception $exception) { } catch (\Exception $exception) {
$errors[] = $exception->getMessage() . ' in email ' . $user[0]; $errors[] = $exception->getMessage() . ' in email ' . $user[0];
} }
$user = fgetcsv($file);
} }
fclose($file); fclose($file);
@ -80,4 +72,4 @@ class CSVImportController extends Controller {
Response::respondSuccess($errors); Response::respondSuccess($errors);
} }
} }