Some small fixes.

This commit is contained in:
James Cole
2015-07-07 10:05:11 +02:00
parent 76a1b2cd51
commit 3172bc90da
3 changed files with 22 additions and 27 deletions

View File

@@ -19,7 +19,6 @@ use Session;
class Wizard implements WizardInterface
{
/**
* @param Reader $reader
* @param array $map
@@ -33,11 +32,12 @@ class Wizard implements WizardInterface
/*
* Loop over the CSV and collect mappable data:
*/
$keys = array_keys($map);
foreach ($reader as $index => $row) {
if (($hasHeaders && $index > 1) || !$hasHeaders) {
if ($this->useRow($hasHeaders, $index)) {
// collect all map values
foreach ($map as $column => $irrelevant) {
// check if $irrelevant is mappable!
foreach ($keys as $column) {
$values[$column][] = $row[$column];
}
}
@@ -52,7 +52,6 @@ class Wizard implements WizardInterface
return $values;
}
/**
* @param array $roles
* @param mixed $map
@@ -120,7 +119,6 @@ class Wizard implements WizardInterface
return true;
}
/**
* @param array $map
*
@@ -168,4 +166,15 @@ class Wizard implements WizardInterface
}
/**
* @param bool $hasHeaders
* @param int $index
*
* @return bool
*/
protected function useRow($hasHeaders, $index)
{
return ($hasHeaders && $index > 1) || !$hasHeaders;
}
}