Ejemplo n.º 1
0
 /**
  * Set url path.
  *
  * @param StringObject|string $path Url path.
  *
  * @throws UrlObjectException
  * @return $this
  */
 public function setPath($path)
 {
     try {
         $path = new StringObject($path);
     } catch (\Exception $e) {
         throw new UrlObjectException($e->getMessage());
     }
     if ($path != '') {
         $path->trimLeft('/');
         $this->path = '/' . $path->val();
     } else {
         $this->path = $path->val();
     }
     $this->rebuildUrl();
     return $this;
 }
Ejemplo n.º 2
0
 public function testTrimLeft2()
 {
     $s = new StringObject('a b c');
     $s->trimLeft('a')->trim();
     $this->assertSame('b c', $s->val());
 }