MCPcopy Create free account
hub / github.com/Rello/analytics / positionalImportMapping

Method positionalImportMapping

lib/Service/DataloadService.php:738–757  ·  view source on GitHub ↗

@param list > $columns * @param list $header * @param list > $rows * @return array */

(array $columns, array $header, array $rows)

Source from the content-addressed store, hash-verified

736 * @return array<string,mixed>
737 */
738 private function positionalImportMapping(array $columns, array $header, array $rows): array
739 {
740 $count = count($columns);
741 if (count($header) !== $count) {
742 throw new FlexibleStorageException('invalid_source_columns', 'The import must have one field for each dataset column, in the same order.');
743 }
744 foreach ($rows as $index => $row) {
745 if (!is_array($row) || count($row) !== $count) {
746 throw new FlexibleStorageException('invalid_source_row', 'Each imported row must have one field for each dataset column.', ['record' => $index]);
747 }
748 }
749 return [
750 'schemaVersion' => 1,
751 'sourceHeader' => $header,
752 'columns' => array_map(static fn (array $column, int $index): array => [
753 'column' => $column['ref'],
754 'sourceIndex' => $index,
755 ], $columns, array_keys($columns)),
756 ];
757 }
758
759 private function getDataloadMetadata(int $dataloadId, bool $enforceOwnership)
760 {

Callers 2

importClipboardMethod · 0.95
importFileMethod · 0.95

Calls 1

countFunction · 0.50

Tested by

no test coverage detected