Return string if not multi-value; add delete_previous flag #194
This commit is contained in:
@@ -44,12 +44,18 @@ class ImporterService extends BaseService
|
|||||||
* Converted into a multi-dimensional array
|
* Converted into a multi-dimensional array
|
||||||
*
|
*
|
||||||
* @param $field
|
* @param $field
|
||||||
* @return array
|
* @return array|string
|
||||||
*/
|
*/
|
||||||
public function parseMultiColumnValues($field): array
|
public function parseMultiColumnValues($field)
|
||||||
{
|
{
|
||||||
$ret = [];
|
$ret = [];
|
||||||
$split_values = explode(';', $field);
|
$split_values = explode(';', $field);
|
||||||
|
|
||||||
|
# No multiple values in here, just a straight value
|
||||||
|
if(\count($split_values) === 1) {
|
||||||
|
return $split_values[0];
|
||||||
|
}
|
||||||
|
|
||||||
foreach($split_values as $value) {
|
foreach($split_values as $value) {
|
||||||
|
|
||||||
# This isn't in the query string format, so it's
|
# This isn't in the query string format, so it's
|
||||||
@@ -80,8 +86,9 @@ class ImporterService extends BaseService
|
|||||||
/**
|
/**
|
||||||
* Import flights
|
* Import flights
|
||||||
* @param $csv_str
|
* @param $csv_str
|
||||||
|
* @param bool $delete_previous
|
||||||
*/
|
*/
|
||||||
public function importFlights($csv_str)
|
public function importFlights($csv_str, bool $delete_previous=true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ class ImporterTest extends TestCase
|
|||||||
public function testMultiFieldValues()
|
public function testMultiFieldValues()
|
||||||
{
|
{
|
||||||
$tests = [
|
$tests = [
|
||||||
|
[
|
||||||
|
'input' => 'gate',
|
||||||
|
'expected' => 'gate'
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'input' => 'gate;cost index',
|
'input' => 'gate;cost index',
|
||||||
'expected' => [
|
'expected' => [
|
||||||
|
|||||||
Reference in New Issue
Block a user