Saeghe is a difficult name to pronounce. Therefore, Saeghe project has been renamed to phpkg.
This website no longer receives updates.
Please visit phpkg website at phpkg.com
The Filename
class extends Datatype Text
class.
You can use it to keep any filename as a string.
It also gives you access to an API that you can see in the following.
Note For more information on the
Text
class, please read its documentation
You can pass the filename to the constructor:
use Saeghe\FileManager\Filesystem\Filename;
$filename = new Filename('filename');
echo $filename; // Output: 'filename'
echo $filename->string(); // Output: 'filename'
$filename = new Filename('.filename');
echo $filename; // Output: '.filename'
echo $filename->string(); // Output: '.filename'
Here you can see a list of the available methods on the filename:
It returns a Directory object by appending the filename to the given root directory.
public function directory(Directory $root): Directory
$filename = new Filename('subdirectory');
$result = $filename->directory(Directory::from_string('/home/user'));
assert_true($result instanceof Directory);
assert_true('/home/user/subdirectory' === $result->path->string());
It returns a File object by appending the filename to the given root directory.
public function file(Directory $root): File
$filename = new Filename('filename');
$result = $filename->file(Directory::from_string('/home/user'));
assert_true($result instanceof File);
assert_true('/home/user/filename' === $result->path->string());
It returns a Symlink object by appending the filename to the given root directory.
public function symlink(Directory $root): Symlink
$filename = new Filename('symlink');
$result = $filename->symlink(Directory::from_string('/home/user'));
assert_true($result instanceof Symlink);
assert_true('/home/user/symlink' === $result->path->string());