zeek / php-utils
A collection of functions that provide basic PHP utility functionality.
Installs: 10 918
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 16
Forks: 1
Open Issues: 0
Requires
- php: >=5.6
Requires (Dev)
- codacy/coverage: ^1.4
- codeception/codeception: 2.3.9
- mikey179/vfsstream: ^1.6
This package is auto-updated.
Last update: 2024-11-09 21:52:44 UTC
README
Purpose
Utility functions to help alleviate some common use cases.
Safe Read
safe_read( $item, $key )
Useful for accessing something without having to wrap it with empty
or isset
checks constantly.
Returns false
if it's unable to find the item. Works with both objects and arrays.
Is Constant True
is_constant_true( $constant )
Checks the following in order:
- Constant is defined
- Constant is
true
Helpful to avoid always having to check if the constant is defined before checking the value.
Returns either true
or false
.
Get File
get_file( $filename, $extension )
Checks that the file exists and is readable.
Allowable file types are:
- xml
- sql
- txt
- json
Returns the data of the file or false
if it failed.
Recursively Remove Directory
rrmdir( $dir )
Recursively delete a directory and all files and directories inside it.
This is useful because PHP's rmdir
does not delete a directory if anything exists inside of it.
Format Currency
Formats the given value with two decimal places, prefixed with a dollar sign.
format_currency( 1.5 ) // $1.50