public static function factory (array $record)
    {
        if (!array_key_exists('fields', $record)) {
            throw new InvalidArgumentException("Missing 'fields' index in record array");
        }
        $fields = array_map(array('HAB\Pica\Record\Field', 'factory'), $record['fields']);
        $type = null;
        $typePredicate = Field::match('002@/00');
        foreach ($fields as $field) {
            if ($typePredicate($field)) {
                $typeSubfield = $field->getNthSubfield('0', 0);
                if ($typeSubfield) {
                    $type = $typeSubfield->getValue();
                    break;
                }
            }
        }
        if ($type === null) {
            throw new InvalidArgumentException("Missing type field (002@/00$0)");
        }
        if ($type[0] === 'T') {
            return new AuthorityRecord($fields);
        } else {
            return new TitleRecord($fields);
        }
    }
public static function factory (array $record)
    {
        if (!array_key_exists('fields', $record)) {
            throw new InvalidArgumentException("Missing 'fields' index in record array");
        }
        $fields = array_map(array('HAB\Pica\Record\Field', 'factory'), $record['fields']);
        $type = null;
        $typePredicate = Field::match('002@/00');
        foreach ($fields as $field) {
            if ($typePredicate($field)) {
                $typeSubfield = $field->getNthSubfield('0', 0);
                if ($typeSubfield) {
                    $type = $typeSubfield->getValue();
                    break;
                }
            }
        }
        if ($type === null) {
            throw new InvalidArgumentException("Missing type field (002@/00$0)");
        }
        if ($type[0] === 'T') {
            return new AuthorityRecord($fields);
        } else {
            return new TitleRecord($fields);
        }
    }
public static function factory ( array $ record ) { if ( ! array_key_exists ( 'fields' , $ record ) ) { throw new InvalidArgumentException ( "Missing 'fields' index in record array" ) ; } $ fields = array_map ( array ( 'HAB\Pica\Record\Field' , 'factory' ) , $ record [ 'fields' ] ) ; $ type = null ; $ typePredicate = Field :: match ( '002@/00' ) ; foreach ( $ fields as $ field ) { if ( $ typePredicate ( $ field ) ) { $ typeSubfield = $ field -> getNthSubfield ( '0' , 0 ) ; if ( $ typeSubfield ) { $ type = $ typeSubfield -> getValue ( ) ; break ; } } } if ( $ type === null ) { throw new InvalidArgumentException ( "Missing type field (002@/00$0)" ) ; } if ( $ type [ 0 ] === 'T' ) { return new AuthorityRecord ( $ fields ) ; } else { return new TitleRecord ( $ fields ) ; } }
Return a new record based on its array representation.

Returns either a {@link TitleRecord} or a {@link AuthorityRecord}
depending on the field 002@ which encodes the record type.

@throws InvalidArgumentException Missing type field
@throws InvalidArgumentException Missing `fields' index

@param  array $record Array representation of a record
@return TitleRecord|AuthorityRecord New record instance
Return a new record based on its array representation .