original_string: public function matchPackageVersionEntities($availableVersions, $wantedVersion)
      {
          if (empty($availableVersions)) {
              $result = null;
          } else {
              $keys = [];
              foreach ($availableVersions as $pv) {
                  $keys[$pv->getVersion()] = $pv;
              }
              $bestKey = $this->matchPackageVersions(array_keys($keys), $wantedVersion);
              $result = $keys[$bestKey];
          }
  
          return $result;
      }
code: public function matchPackageVersionEntities($availableVersions, $wantedVersion)
      {
          if (empty($availableVersions)) {
              $result = null;
          } else {
              $keys = [];
              foreach ($availableVersions as $pv) {
                  $keys[$pv->getVersion()] = $pv;
              }
              $bestKey = $this->matchPackageVersions(array_keys($keys), $wantedVersion);
              $result = $keys[$bestKey];
          }
  
          return $result;
      }
code_tokens: public function matchPackageVersionEntities ( $ availableVersions , $ wantedVersion ) { if ( empty ( $ availableVersions ) ) { $ result = null ; } else { $ keys = [ ] ; foreach ( $ availableVersions as $ pv ) { $ keys [ $ pv -> getVersion ( ) ] = $ pv ; } $ bestKey = $ this -> matchPackageVersions ( array_keys ( $ keys ) , $ wantedVersion ) ; $ result = $ keys [ $ bestKey ] ; } return $ result ; }
docstring: Guess the best package version entity corresponding to a list of entity instances.
  
  @param \CommunityTranslation\Entity\Package\Version[] $availableVersions
  @param string $wantedVersion
  
  @return \CommunityTranslation\Entity\Package\Version|null Returns null if $availableVersions is empty, an entity instance otherwise
docstring_tokens: Guess the best package version entity corresponding to a list of entity instances .