code: private function setPath($path)
      {
          if ('' === $path) {
              $this->path = $path;
  
              return;
          }
          if (
              false !== filter_var('http://example.com'.$path, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)
              && '/' === $path{0}
          ) {
              $this->path = $path;
          } else {
              throw new \InvalidArgumentException("Invalid path");
          }
      }
docs: @param string $path
  
  @throws \InvalidArgumentException