Example #1
0
 /**
  * Test if this URL matches all available parts of a given URL
  *
  * @param Url $url Comparison URL
  * @return bool This URL matches all available parts of the given URL
  */
 public function matches(Url $url)
 {
     // Test the scheme
     $urlScheme = $url->getScheme();
     if ($urlScheme !== null && $this->getScheme() !== $urlScheme) {
         return false;
     }
     // Test the user
     $urlUser = $url->getUser();
     if ($urlUser !== null && $this->getUser() !== $urlUser) {
         return false;
     }
     // Test the password
     $urlPassword = $url->getPassword();
     if ($urlPassword !== null && $this->getPassword() !== $urlPassword) {
         return false;
     }
     // Test the host
     $urlHost = $url->getHost();
     if ($urlHost !== null && $this->getHost() !== $urlHost) {
         return false;
     }
     // Test the port
     $urlPort = $url->getPort();
     if ($urlPort !== null && $this->getPort() !== $urlPort) {
         return false;
     }
     // Test the path
     $urlPath = $url->getPath();
     if ($urlPath !== null && $this->getPath() !== $urlPath) {
         return false;
     }
     // Test the query
     $urlQuery = $url->getQuery();
     if (serialize($this->getQuery()) !== serialize($urlQuery)) {
         return false;
     }
     // Test the fragment
     $urlFragment = $url->getFragment();
     if ($urlFragment !== null && $this->getFragment() !== $urlFragment) {
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Return the a complete serialized object URL
  *
  * @param array $override Override components
  * @return string Serialized URL
  */
 protected function getUrlInternal(array &$override = [])
 {
     parent::getUrlInternal($override);
     // Prepare the local object locator
     $override['object'] = isset($override['object']) ? $override['object'] : $this->locator->toUrl(!empty($override['canonical']));
     return "{$override['scheme']}{$override['user']}{$override['pass']}{$override['host']}{$override['port']}" . "{$override['path']}{$override['object']}{$override['query']}{$override['fragment']}";
 }