Converter
in package
implements
ConverterInterface
Convert paths relative from 1 file to another.
E.g. ../../images/icon.jpg relative to /css/imports/icons.css becomes ../images/icon.jpg relative to /css/minified.css
Please report bugs on https://github.com/matthiasmullie/path-converter/issues
Tags
Table of Contents
Interfaces
- ConverterInterface
- Convert file paths.
Properties
Methods
- __construct() : mixed
- convert() : string
- Convert paths relative from 1 file to another.
- dirname() : string
- Attempt to get the directory name from a path.
- normalize() : string
- Normalize path.
- shared() : string
- Figure out the shared path of 2 locations.
Properties
$from
protected
string
$from
$to
protected
string
$to
Methods
__construct()
public
__construct(string $from, string $to[, string $root = '' ]) : mixed
Parameters
- $from : string
-
The original base path (directory, not file!)
- $to : string
-
The new base path (directory, not file!)
- $root : string = ''
-
Root directory (defaults to
getcwd
)
convert()
Convert paths relative from 1 file to another.
public
convert(string $path) : string
E.g. ../images/img.gif relative to /home/forkcms/frontend/core/layout/css should become: ../../core/layout/images/img.gif relative to /home/forkcms/frontend/cache/minified_css
Parameters
- $path : string
-
The relative path that needs to be converted
Return values
string —The new relative path
dirname()
Attempt to get the directory name from a path.
protected
dirname(string $path) : string
Parameters
- $path : string
Return values
stringnormalize()
Normalize path.
protected
normalize(string $path) : string
Parameters
- $path : string
Return values
stringshared()
Figure out the shared path of 2 locations.
protected
shared(string $path1, string $path2) : string
Example: /home/forkcms/frontend/core/layout/images/img.gif and /home/forkcms/frontend/cache/minified_css share /home/forkcms/frontend
Parameters
- $path1 : string
- $path2 : string