From ae6c2da1de60beefc0611755948a62633761cdf0 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 22 Sep 2020 06:32:48 +0000 Subject: [PATCH] Remove split. #502 --- src/Command/ImportSAPBatteryCommand.php | 47 +++++++------------------ 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/Command/ImportSAPBatteryCommand.php b/src/Command/ImportSAPBatteryCommand.php index 2a4db8d2..f26e0909 100644 --- a/src/Command/ImportSAPBatteryCommand.php +++ b/src/Command/ImportSAPBatteryCommand.php @@ -111,44 +111,23 @@ class ImportSAPBatteryCommand extends Command $dupe_brands[] = strtoupper($clean_brand); } - // need to check if size has / - $pos = stripos($clean_size, '/'); - $clean_sizes = []; - if ($pos == false) + // size hash + if (!isset($this->batt_size_hash[$clean_size])) { - // no '/' in size - $clean_sizes[] = $this->normalizeName($clean_size); + $size = new SAPBatterySize(); + $size->setName(strtoupper($clean_size)); + + $em->persist($size); + + $this->batt_size_hash[$clean_size] = $size; + + // add to list of added sizes + error_log('Adding size ' . strtoupper($clean_size)); + $added_sizes[strtoupper($clean_size)] = strtoupper($clean_size); } else { - // need to explode - $sizes = explode('/', $clean_size); - foreach ($sizes as $size) - { - $clean_sizes[] = $this->normalizeName(trim($size)); - } - } - - foreach ($clean_sizes as $c_size) - { - // size hash - if (!isset($this->batt_size_hash[$c_size])) - { - $size = new SAPBatterySize(); - $size->setName(strtoupper($c_size)); - - $em->persist($size); - - $this->batt_size_hash[$c_size] = $size; - - // add to list of added sizes - error_log('Adding size ' . strtoupper($c_size)); - $added_sizes[strtoupper($c_size)] = strtoupper($c_size); - } - else - { - $dupe_sizes[] = strtoupper($c_size); - } + $dupe_sizes[] = strtoupper($clean_size); } // battery hash