private function findOrNewRecord(array $recordsByHandle, array $definition, string $handle): Model
    {
        $record = new $definition['class']();
        if (array_key_exists($handle, $recordsByHandle)) {
            $existing = $recordsByHandle[$handle];
            if (get_class($record) == get_class($existing)) {
                $record = $existing;
            } else {
                $record->id = $existing->id;
                $record->setAttributes($existing->getAttributes());
            }
        }

        return $record;
    }
private function findOrNewRecord(array $recordsByHandle, array $definition, string $handle): Model
    {
        $record = new $definition['class']();
        if (array_key_exists($handle, $recordsByHandle)) {
            $existing = $recordsByHandle[$handle];
            if (get_class($record) == get_class($existing)) {
                $record = $existing;
            } else {
                $record->id = $existing->id;
                $record->setAttributes($existing->getAttributes());
            }
        }

        return $record;
    }
private function findOrNewRecord ( array $ recordsByHandle , array $ definition , string $ handle ) : Model { $ record = new $ definition [ 'class' ] ( ) ; if ( array_key_exists ( $ handle , $ recordsByHandle ) ) { $ existing = $ recordsByHandle [ $ handle ] ; if ( get_class ( $ record ) == get_class ( $ existing ) ) { $ record = $ existing ; } else { $ record -> id = $ existing -> id ; $ record -> setAttributes ( $ existing -> getAttributes ( ) ) ; } } return $ record ; }
Find record from records by handle or new record.

@param Model[] $recordsByHandle
@param array   $definition
@param string  $handle

@return Model
Find record from records by handle or new record .