@param string $path
@param string $givenType
@param string $wishedType

@return self
548183
public static function createInvalidDataType(string $path, string $givenType, string $wishedType): self
    {
        return new self(
            sprintf('There is an invalid data type "%s", needed "%s" at path: "%s"', $givenType, $wishedType, $path)
        );
    }
1023803
private function addPath($path)
    {
        $path = $this->resolvePath($path);

        if ($this->validatePath($path)) {
            $this->paths[] = $path;
        }

        return $this;
    }
8467
public function setPath($type, $path)
	{
		if (!array_key_exists($type, $this->paths))
		{
			throw new \Exception(\App::get('language')->txt('Unknown asset path type of %s given.', $type));
		}

		$path = trim((string) $path);

		// Add separators as needed
		$path = DS . trim($path, DS);

		// Add to list of paths
		$this->paths[$type] = $path;

		return $this;
	}
746319
public function withPath(Path $path): self
    {
        $url = Structure::fromString((string) $this)
            ->withPath(
                new UrlPath((string) $path)
            )
            ->withQuery(new NullQuery)
            ->withFragment(new NullFragment);

        return new self(
            (string) $url
        );
    }
901103
public function isCorrectType($type, $path)
	{
		if ( ! $type)
		{
			return true;
		}

		if ( ! isset($this->typeCache[$path]))
		{
			$this->typeCache[$path] = is_file($path) ? 'file' : 'dir';
		}

		return $this->typeCache[$path] === $type;
	}
737455
public static function fromString($path)
    {
        if (!file_exists($path)) {
            throw new InvalidArgumentType(
                '$path',
                'existing file',
                $path
            );
        }

        return new static(
            array(
                'inputUri' => $path,
                'fileName' => basename($path),
                'fileSize' => filesize($path),
            )
        );
    }
859950
public function setPath(string $path): self
    {
        parent::setPath($path);
        $this->directory = new Directory(\dirname($path));

        return $this;
    }
1029897
public function withPath($path)
    {
        // if the path is absolute, then clear basePath
        if (substr($path, 0, 1) == '/') {
            $clone->basePath = '';
        }
        $this->path = $this->filterQuery($path);

        return $this;
    }
544289
public function webDir(string $path): self
    {
        $this->validatePathIsRelativeToProject($path, __METHOD__);
        $this->webDir = rtrim($path, '/');

        return $this;
    }
1266909
public static function setPathCreated(string $path): void
    {
        if (!self::$registered) {
            self::$registered = self::registerShutdownFunction();
        }
        $realPath = realpath($path);
        if (!$realPath) {
            throw new DoctrineStaticMetaException("path $path does not seem to exist");
        }
        self::$pathsCreated[$realPath] = $realPath;
    }
575462
public static function create(string $path, string $asName = null, string $contentType = null): FileDownload
    {
        $self = new static(new File($path));

        if ($asName !== null) {
            $self->setAsName($asName);
        }

        if ($contentType !== null) {
            $self->setContentType($contentType);
        }

        return $self;
    }
1330505
public static void get(String path, String acceptType, Route route) {
        getInstance().get(path, acceptType, route);
    }
726679
public function setPath($path)
	{
		if ( ! $this->files->exists($path) ) {
			$result = $this->files->put($path, '{}');
			if ( $result === false ) {
				throw new NotWritableException("Could not write to $path.");
			}
		}

		if ( ! $this->files->isWritable($path) ) {
			throw new NotWritableException("$path is not writable.");
		}

		$this->path = $path;
	}
806002
public function cacheDir(string $path): self
    {
        $this->validatePathIsRelativeToProject($path, __METHOD__);
        $this->cacheDir = rtrim($path, '/');

        return $this;
    }
191739
public function setCACertificates($path, $type)
    {
        if (!in_array($type, array('capath', 'cainfo'))) {
            throw new \OtherCode\Rest\Exceptions\RestException('Invalid param "type" in for ' . __METHOD__ . 'method.');
        }

        $this->ssl_verifypeer = true;
        $this->ssl_verifyhost = 2;
        $this->$type = $path;
        return $this;
    }
1111071
private function load(string $path): self
    {
        return $this
            ->setExtensionFromPath($path)
            ->loadFromPath($path)
            ->updateDimensions();
    }
182154
public static RouteImpl create(final String path, String acceptType, final Route route) {
        if (acceptType == null) {
            acceptType = DEFAULT_ACCEPT_TYPE;
        }
        return new RouteImpl(path, acceptType, route) {
            @Override
            public Object handle(Request request, Response response) throws Exception {
                return route.handle(request, response);
            }
        };
    }