src/URI.php
private function setPath($path)
	{
		$directory = dirname($path);
		$file = basename($path);

		// If dirname is '.'. Then remove it.
		if ($directory === '.') {
			$directory = '';
		}

		// If the path ends with '/'. Then there is no file.
		if (substr($path, -1) === static::DELIMITER_PATH) {
			$directory = $path;
			$file = '';
		}

		// If the dirname and basename are both set. Then add the missing '/'.
		if (substr($directory, -1) !== static::DELIMITER_PATH && $directory !== '' && $file !== '') {
			$directory .= static::DELIMITER_PATH;
		}

		$this->setDirectory($directory);
		$this->setFile($file);

		return $this;
	}
private function setPath($path)
	{
		$directory = dirname($path);
		$file = basename($path);

		// If dirname is '.'. Then remove it.
		if ($directory === '.') {
			$directory = '';
		}

		// If the path ends with '/'. Then there is no file.
		if (substr($path, -1) === static::DELIMITER_PATH) {
			$directory = $path;
			$file = '';
		}

		// If the dirname and basename are both set. Then add the missing '/'.
		if (substr($directory, -1) !== static::DELIMITER_PATH && $directory !== '' && $file !== '') {
			$directory .= static::DELIMITER_PATH;
		}

		$this->setDirectory($directory);
		$this->setFile($file);

		return $this;
	}
Set the path.

@param string $path
@return $this