original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Find record from records by handle or new record.
  
  @param Model[] $recordsByHandle
  @param array   $definition
  @param string  $handle
  
  @return Model
docstring_tokens: Find record from records by handle or new record .