Download the PHP package nekland/tools without Composer
On this page you can find all versions of the php package nekland/tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nekland/tools
More information about nekland/tools
Files in nekland/tools
Informations about the package tools
Nekland Tools
Just some classes helping to code with PHP in general. No dependencies. High quality code.
This repository follows semver.
Installation
Reference
This library provide some tools to help you with your developments.
Here is the list of tools it provides:
- StringTools
- ArrayTools
- EqualableInterface
- DateTimeComparator
- TemporaryFile
- TemporaryDirectory
StringTools class
Encoding arguments are optionals.
::camelize
$strstring input$from(optional, default "_") input string format (can be "-" or "_")$encoding(optional, default "UTF-8") encoding of your input string$normalizedecide either you want to normalize (remove special characters) or not, that's what you want in most cases when camelizing
::startsWith
Say if the given string starts with needle or not.
$strstring input$startstring it should starts with
::endsWith
Say if the given string ends with needle or not.
$strstring input$endstring it should ends with
::removeStart
Removes the start of the string if it matches with the given one.
$strstring input$toRemovestring to remove at the start of$str
::removeEnd
Removes the end of the string if it matches with the given text to remove.
$strstring input$toRemovestring to remove at the end of$str
::contains
$strstring input$needlepotentially contained string
::mb_ucfirst
Adds missing multi-byte PHP function for ucfirst standard function.
$strstring input$encoding(optional, default "UTF-8") encoding of your input string
ArrayTools class
::removeValue
$arrayinput array passed by reference$valueThe value to remove from the $array
EqualableInterface
Helps you equals on objects on a similar way as java.
equals
Method that you must implements to check if the object taking as parameter is equals or not.
DateTimeComparator class
For following methods lowest and greatest, you can provide unlimited DateTimeInterface objects.
Please note that non DateTimeInterface objects will be ignored by functions.
::greatest
Compare \DateTimeInterface from parameters and return the greatest
::lowest
Compare \DateTimeInterface from parameters and return the lowest
Temporary file management
The class TemporaryFile helps you to create temporary file with ease.
::__construct()
Examples:
::setContent & ::getContent
::getPathname()
Returns the complete path to the file (ie: /tmp/generated-folder/filename)
::remove()
Removes the file from filesystem.
Temporary directory management
::__construct()
Examples:
::getTemporaryFile()
Create a TemporaryFile from the directory generated.
::remove()
Removes the directory.
If force is specified to true, it will remove the directory even if it has files inside.
::getPathname()
Returns the complete path to the folder (ie: /tmp/folder-name)