public function mapSourceToDestinationRow($sourceRow) { $mappedRow = array(); foreach ($this->getMapping() as $destinationColumn => $sourceColumn) { $value = null; if ($sourceColumn || $sourceColumn != '') { $hasKey = array_key_exists($sourceColumn, $sourceRow); if ($hasKey) { $value = $sourceRow[$sourceColumn]; } else { // if key doesn't exists, try to resolve by path (key.subkey.subsubkey etc.) $value = Arr::path($sourceRow, $sourceColumn); } } $mappedRow[$destinationColumn] = $value; } if ($this->includeUnmappedColumns) { foreach ($sourceRow as $sourceKey => $sourceValue) { if (!array_key_exists($sourceKey, $this->getMapping())) { $mappedRow[$sourceKey] = $sourceValue; } } } return $mappedRow; }
/** * Accept? * When the filter returns false for one or more columns, the row will be ignored * @param array Row * @return bool True if accepted, false if not */ public function accept($row) { $accept = 1; $params = $this->params ?: array(); foreach ($this->columns as $column) { $value = Arr::get($row, $column); if (!$this->hasCustomParamSignature) { // prepend value as first param and columns as second array_unshift($params, $value, $column); } else { // replace placeholders with value $params = array(); foreach ($this->valuePlaceHolderIndexes as $index) { $params[$index] = strtr($params[$index], array(':value' => $value)); } } $accept &= call_user_func_array($this->callable, $params) === true; } return (bool) $accept; }