Exemplo n.º 1
0
 /**
  * Gets the name of a URL.
  *
  * @static
  * @param string $sLink The link
  * @return string The name of the domain with the first letter capitalized.
  */
 public static function name($sLink)
 {
     $oStr = new Str();
     $sLink = $oStr->upperFirst(preg_replace('#(^https?://|www\\.|\\.[a-z]{2,4}/?$)#i', '', $oStr->lower($sLink)));
     unset($oStr);
     return $sLink;
 }
 /**
  * Detect the user's preferred language.
  *
  * @return string First two letters of the languages ​​of the client browser.
  */
 public function getLanguage()
 {
     $oStr = new Str();
     $sLang = explode(',', Server::getVar(Server::HTTP_ACCEPT_LANGUAGE))[0];
     // The rtrim function is slightly faster than chop function
     return $oStr->escape($oStr->lower(substr(rtrim($sLang), 0, 2)));
     unset($oStr);
 }