/** * Resolve a path against a given base path. * * @param AbsolutePathInterface $basePath The base path. * @param PathInterface $path The path to resolve. * * @return AbsolutePathInterface The resolved path. */ public function resolve(AbsolutePathInterface $basePath, PathInterface $path) { if ($path instanceof AbsolutePathInterface) { return $path; } if ($path instanceof RelativeWindowsPathInterface) { if ($path->isAnchored()) { return $path->joinDrive($basePath->drive()); } if ($path->hasDrive() && !$path->matchesDrive($basePath->drive())) { return $path->toAbsolute(); } } return $basePath->join($path); }
/** * Get the the drive specifier of the supplied path, returning null if the * path is a non-Windows path. * * @param PathInterface $path The path. * * @return string|null The drive specifier. */ protected function pathDriveSpecifier(PathInterface $path) { if ($path instanceof WindowsPathInterface) { return $path->drive(); } return null; }
/** * Construct a new invalid path exception. * * @param PathInterface $path The invalid path. * @param Exception|null $previous The cause, if available. */ public function __construct(PathInterface $path, Exception $previous = null) { $this->path = $path; parent::__construct(sprintf("Invalid path %s. %s", var_export($path->string(), true), $this->reason()), 0, $previous); }