/** * 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; }
public function testTrimLeft2() { $s = new StringObject('a b c'); $s->trimLeft('a')->trim(); $this->assertSame('b c', $s->val()); }