/** * Append a field to the record. * * @see Record::append() * * @throws InvalidArgumentException Field level other than 0 * @throws InvalidArgumentException Field already in record * * @param Field $field Field to append * @return void */ public function append(Field $field) { if ($field->getLevel() !== 0) { throw new InvalidArgumentException("Invalid field level {$field->getLevel()}"); } return parent::append($field); }
/** * Append a field to the copy record. * * You can only append field of level 2 to a copy record. * * @see Record::append() * * @throws InvalidArgumentException Field level other than 2 * @throws InvalidArgumentException Item number mismatch * @throws InvalidArgumentException Field already in record * * @param Field $field Field to append * @return void */ public function append(Field $field) { if ($field->getLevel() !== 2) { throw new InvalidArgumentException("Invalid field level: {$field->getLevel()}"); } if ($this->getItemNumber() === null) { $this->setItemNumber($field->getOccurrence()); } if ($field->getOccurrence() != $this->getItemNumber()) { throw new InvalidArgumentException("Item number mismatch: {$this->getItemNumber()}, {$field->getOccurrence()}"); } return parent::append($field); }