Download the PHP package mattgorle/filename-suffixer without Composer
On this page you can find all versions of the php package mattgorle/filename-suffixer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mattgorle/filename-suffixer
More information about mattgorle/filename-suffixer
Files in mattgorle/filename-suffixer
Package filename-suffixer
Short Description Ensures unique filenames by adding a numeric suffix
License mit
Informations about the package filename-suffixer
Filename Suffixer
Ensures that filenames are unique by appending a suffix to the filename.
If a file with $filename
does not already exist, then the original filename is offered instead of an altered one.
Examples
For a file named test_file.txt
, FilenameSuffixer::suffix
will return:
test_file.txt
if the file does not existtest_file-1.txt
if a file calledtest_file.txt
already existstest_file-2.txt
if files calledtest_file.txt
andtest_file-1.txt
already exist- etc...
Versioning
This project follows semantic versioning.
Installation
Usage
Customising behaviour
I have tried to select sensible defaults, but you can modify several parameters to suit your
individual use case by changing the value of the static properties on FilenameSuffixer
.
You can customise the following:
Option | Default Value | Property |
---|---|---|
File extension separator | . |
FilenameSuffixer::$extensionSeparator |
Suffix separator | - |
FilenameSuffixxer::$suffixSeparator |
Path separator | / |
FilenameSuffixer::$pathSeparator |
Suffix starting number | 1 |
FilenameSuffixer::$suffixStartsAt |
Examples
Resetting the suffixer after changing defaults
Help, I've changed loads of stuff and now I can't find my way back!!! :sob:
Simply call FilenameSuffixer::reset()
and the initial defaults will be reinstated.
Honestly, I don't know if this is going to be a useful feature - it came up in testing and it feels more like a consequence of implementing this as a static class. Probably needs some thought!