setBasePath($basePath); } } /** * Returns site's base path, or file with base path prepended. * * $file is appended to the base path for simplicity. * * @param string|null $file * @throws RuntimeException * @return string */ public function __invoke($file = null) { if ($this->basePath === null) { throw new RuntimeException('No base path provided'); } if ($file !== null && $file !== '') { return sprintf( '%s/%s', $this->basePath, ltrim($file, '/') ); } return $this->basePath; } /** * Set the base path. * * @param string $basePath * @return self */ public function setBasePath($basePath) { $this->basePath = rtrim($basePath, '/'); return $this; } }