diff --git a/src/Objects/DataRow.php b/src/Objects/DataRow.php index d658699..33aaaaf 100755 --- a/src/Objects/DataRow.php +++ b/src/Objects/DataRow.php @@ -51,11 +51,18 @@ public function getKeyDataItems() { public function prepare(array $keyFields, array $fieldMap, callable $dataItemManipulator) { + $this->validate(); $this->setKeyFields($keyFields); $this->mapFields($fieldMap); $this->callDataItemManipulator($dataItemManipulator); } + private function validate() { + if (!$this->dataItems) { + throw new Exception('Data row contains no data items. The specified source may be producing an invalid data row.'); + } + } + private function setKeyFields(array $keyFields) { foreach($this->dataItems as $key => $dataItem) { if (in_array($dataItem->fieldName, $keyFields)) {