original_string: private function selectRestVersion($channelXml, $supportedVersions)
      {
          $channelXml->registerXPathNamespace('ns', self::CHANNEL_NS);
  
          foreach ($supportedVersions as $version) {
              $xpathTest = "ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']";
              $testResult = $channelXml->xpath($xpathTest);
              if (count($testResult) > 0) {
                  return array('version' => $version, 'baseUrl' => (string) $testResult[0]);
              }
          }
  
          return null;
      }
code: private function selectRestVersion($channelXml, $supportedVersions)
      {
          $channelXml->registerXPathNamespace('ns', self::CHANNEL_NS);
  
          foreach ($supportedVersions as $version) {
              $xpathTest = "ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']";
              $testResult = $channelXml->xpath($xpathTest);
              if (count($testResult) > 0) {
                  return array('version' => $version, 'baseUrl' => (string) $testResult[0]);
              }
          }
  
          return null;
      }
code_tokens: private function selectRestVersion ( $ channelXml , $ supportedVersions ) { $ channelXml -> registerXPathNamespace ( 'ns' , self :: CHANNEL_NS ) ; foreach ( $ supportedVersions as $ version ) { $ xpathTest = "ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']" ; $ testResult = $ channelXml -> xpath ( $ xpathTest ) ; if ( count ( $ testResult ) > 0 ) { return array ( 'version' => $ version , 'baseUrl' => ( string ) $ testResult [ 0 ] ) ; } } return null ; }
docstring: Reads channel supported REST interfaces and selects one of them
  
  @param $channelXml \SimpleXMLElement
  @param $supportedVersions string[] supported PEAR REST protocols
  @return array|null hash with selected version and baseUrl
docstring_tokens: Reads channel supported REST interfaces and selects one of them