'search', Common::REFERRER_TYPE_SOCIAL_NETWORK => 'social', Common::REFERRER_TYPE_WEBSITE => 'website', Common::REFERRER_TYPE_DIRECT_ENTRY => 'direct', Common::REFERRER_TYPE_CAMPAIGN => 'campaign', ); if (isset($map[$name])) { return $map[$name]; } if ($found = array_search($name, $map)) { return $found; } throw new \Exception("Referrer type '$name' is not valid."); } /** * Returns a URL w/o the protocol type. * * @param string $url * @return string */ function removeUrlProtocol($url) { if (preg_match('/^[a-zA-Z_-]+:\/\//', $url, $matches)) { return substr($url, strlen($matches[0])); } return $url; }