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;
    }