Example #1
0
 /**
  * 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);
 }
Example #2
0
 public function testGetOccurrence()
 {
     $f = new Field('003@', 0);
     $this->assertEquals(0, $f->getOccurrence());
 }