/**
* If there is more than one <link> in the feed entry, find the most appropriate one and return it.
*
* @param array $links Array of <link> elements from the feed entry.
*
* @return \SimpleXMLElement
*/
private function bestLinkForUri(array $links)
{
$linkPrefs = array('', 'self', 'alternate');
foreach ($linkPrefs as $pref) {
foreach ($links as $link) {
$rel = (string) $link['rel'];
if ($rel === $pref) {
return $link;
}
}
}
return array_shift($links);
}