Example #1
0
 /**
  *  Tell whether any generic URI is valid
  *
  * @return bool
  */
 protected function isValidGenericUri()
 {
     $path = $this->path->getUriComponent();
     if (false === strpos($path, ':')) {
         return true;
     }
     $path = explode(':', $path);
     $path = array_shift($path);
     $str = $this->scheme->getUriComponent() . $this->getAuthority();
     return !(empty($str) && strpos($path, '/') === false);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function withoutEmptySegments()
 {
     return $this->withProperty('path', $this->path->withoutEmptySegments());
 }
Example #3
0
File: Path.php Project: BauRo/url
 /**
  * {@inheritdoc}
  */
 public function relativize(Interfaces\Path $path)
 {
     $bSegments = explode(static::$delimiter, $this->withoutDotSegments()->__toString());
     $cSegments = explode(static::$delimiter, $path->withoutDotSegments()->__toString());
     if ('' == end($bSegments)) {
         array_pop($bSegments);
     }
     $key = 0;
     $res = [];
     while (isset($cSegments[$key], $bSegments[$key]) && $cSegments[$key] === $bSegments[$key]) {
         ++$key;
         $res[] = '..';
     }
     return static::createFromArray(array_merge($res, array_slice($cSegments, $key)));
 }