myjw3b / helpful
Some useful classes and functions to help with your everyday php building.
Installs: 55
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Type:project
pkg:composer/myjw3b/helpful
Requires
- php: ^8.0
Requires (Dev)
- clean/phpdoc-md: ^0.19
- phpstan/phpstan: ^1.12
README
Ary Array
| Name | Description |
|---|---|
| arrayToObject | Convert an array to an object. |
| flop_vals | Preserving the keys and flop the values in reverse order. |
| objectToArray | Convert an object to an array. |
Files
| Name | Description |
|---|---|
| check_file | Puts a number before the filename if it exists. |
| deleteDir | Deletes a directory and its contents. |
| make_yr_directory | Creates a directory structure based on the current year and month. |
| mk_dir_writable | Creates a writable directory. |
| reArrayFiles | Re-arranges files array for image uploads. |
| removeEmptySubfolders | Removes empty subfolders. |
| tree | Reads all files and folders in a directory. |
| zip | Zips a directory or file. |
HTML
| Name | Description |
|---|---|
| breadcrumb | Generates a breadcrumb navigation. |
| browse | Generates pagination links based on current page and total items. |
| pagination | Generates a pagination HTML structure. |
| setUpLinks | Sets up links from a comma-separated list of tags. |
| svg_img | Generates an SVG image with a specified width, height, and text. |
| tagCloud | Generates a tag cloud from an associative array of tags and their frequencies. |
Images
| Name | Description |
|---|---|
| get_large_img | Get the large version of an image. |
| get_mime_type | Get the MIME type of a file. |
| resize_image | Resize an image using ImageMagick. |
| resize_uploaded_image | Resize and upload an image. |
| set_im | Set the ImageMagick command. |
| webpImage | Convert an image to webp using GD. |
| Name | Description |
|---|---|
| send | Send an email. |
Number
| Name | Description |
|---|---|
| numberToWord | Convert a number to its word representation. |
| sq | Calculate the price per square foot. |
SQL
| Name | Description |
|---|---|
| decimal | Format a decimal number for USA currency. |
| format | Format a value based on the specified format type. |
Str
Some functions are heavily influenced by Laravel's illuminate\support\Str Class
| Name | Description |
|---|---|
| camel | Convert a value to camel case. |
| clean_url | Clean a URL string. |
| e | Clean a text string. |
| form_element_name | Generate a form element name from a string. |
| fromBase64 | Decode the given Base64 encoded string. |
| headline | Convert various string formats to a capitalized headline. |
| kebab | Convert a camelCase string to kebab-case. |
| lcfirst | Make a string's first character lowercase. |
| length | Return the length of the given string. |
| limit | Limit the number of characters in a string. |
| lower | Convert the given string to lower-case. |
| ltrim | Remove all whitespace from the beginning of a string. |
| p | Print a variable in a readable format. |
| parse_my_url | Parse the current URL into an array of segments. |
| randomString | Generate a random string. |
| removePound | Remove pound signs and dashes from a string. |
| rtrim | Remove all whitespace from the end of a string. |
| snake | Convert a string to snake case. |
| studly | Convert a value to studly caps case. |
| substr | Returns the portion of the string specified by the start and length parameters. |
| swap | Swap keywords in a string according to a mapping array. |
| title | Convert the given string to proper case. |
| toBase64 | Convert the given string to Base64 encoding. |
| trim | Remove all whitespace from both ends of a string. |
| ucfirst | Make a string's first character uppercase. |
| ucsplit | Split a string into pieces by uppercase characters. |
| upper | Convert the given string to upper-case. |
| wordWrap | Wrap a string to a given number of characters using a specified line break. |
Color
Modified and updated to PHP 8 from https://gist.github.com/425464 (c) Rowan Manning
| Name | Description |
|---|---|
| __construct | Class constructor. |
| __get | get magic method. |
| __set | set magic method. |
| __toString | toString magic method. |
| getArray | Get the red, green and blue values of the colour as an array. |
| getHex | Get the HEX code that represents the colour. |
| hexToRgb | Convert a HEX code into RGB. |
| mix | Mix two colours together. |
| modify | Modify the colour's red, green and blue values. |
| randomise | Randomise red, green and blue values of the colour. |
| range | Calculate and return a range of colours between a start and end colour. |
| rgbToHex | Convert red, green and blue values to a HEX code. |
| set | Set the colour's red, green and blue values // Sets the RGB values. |
| setHex | Set the red, green and blue values of the colour with a HEX code. |