/** * Returns the first record found in the string $data, or null if no records found. * * @param $data * @return null|Collection */ public static function fromString($data) { $records = Collection::fromString($data)->toArray(); if (!count($records)) { throw new RecordNotFound(); } return $records[0]; }
/** * @inheritdoc */ public function parse($data) { $records = MarcCollection::fromString($data)->records; return $this->convertRecord($records); }
public function testEmptyCollection() { $source = '<?xml version="1.0" encoding="UTF-8" ?><test></test>'; $collection = Collection::fromString($source); $this->assertCount(0, $collection->toArray()); }