diff --git a/src/php/HAB/Pica/Record/NestedRecord.php b/src/php/HAB/Pica/Record/NestedRecord.php index 57e0ab4be759b5ba42b4bc60e06da26adddbf8e9..5a8f1a5529f3552d72fee1ebb6880602ee3bc55b 100644 --- a/src/php/HAB/Pica/Record/NestedRecord.php +++ b/src/php/HAB/Pica/Record/NestedRecord.php @@ -142,7 +142,7 @@ abstract class NestedRecord extends Record { * @return void */ protected function addRecord (\HAB\Pica\Record\Record $record) { - if (in_array($record, $this->_records, true)) { + if ($this->containsRecord($record)) { throw new \InvalidArgumentException("{$this} already contains {$record}"); } $this->_records []= $record; @@ -163,6 +163,16 @@ abstract class NestedRecord extends Record { unset($this->_records[$index]); } + /** + * Return true if this record contains the requested record. + * + * @param \HAB\Pica\Record\Record Record to check + * @return boolean + */ + protected function containsRecord (\HAB\Pica\Record\Record $record) { + return in_array($record, $this->_records, true); + } + /** * Finalize the clone() operation. *