Download the PHP package regulus/tetra-text without Composer
On this page you can find all versions of the php package regulus/tetra-text. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download regulus/tetra-text
More information about regulus/tetra-text
Files in regulus/tetra-text
Package tetra-text
Short Description A small text/string formatting composer package for Laravel 5 that formats numeric values, money values, phone numbers, and more.
License MIT
Informations about the package tetra-text
TetraText
A small text/string formatting composer package for Laravel 5 that formats numeric values, money values, phone numbers, and more. There are also some limited date functions available.
- Installation
- Available Functions
Installation
To install TetraText, make sure "regulus/tetra-text" has been added to Laravel 5's composer.json
file.
"require": {
"regulus/tetra-text": "0.6.*"
},
Then run php composer.phar update
from the command line. Composer will install the TetraText package. Now, all you have to do is register the service provider and set up TetraText's alias in config/app.php
. Add this to the providers
array:
Regulus\TetraText\TetraTextServiceProvider::class,
And add this to the aliases
array:
'Format' => Regulus\TetraText\Facade::class,
You may use 'TetraText', or another alias, but 'Format' is recommended for the sake of simplicity. TetraText is now ready to go.
Available Functions
Format a string as a number:
Format a string into a dollar value:
The advantage of the money()
function over PHP's number_format()
is that negative dollar values will come out as -$343.00
instead of $-343.00
like they would if you simply concatenated a dollar sign to a string formatted with number_format()
.
Turn a value into a percent of a specified total (and avoid "division by zero" error):
Format a North American phone number:
You may pass the phone()
function a string or an integer. It will automatically strip out non-numeric characters before formatting the variable into a phone number.
Format a Canadian postal code:
Format a boolean as a string:
Add a suffix to a number:
Pluralize an item name based on a specified number:
Pluralize a string based on a specified number:
Get the correct English word prefix for an item name ("a" or "an", based on the sound of the starting syllable):
Convert a string to HTML characters:
Convert a string to a URI slug:
Convert a string to a unique URI slug based on the specified table and field name:
Get the first day of a week:
Get the last day of a week:
Get the first day of a month:
Get the last day of a month:
Convert new lines to paragraphs:
Apply a character limit to a string:
Note:
charLimit()
andwordLimit()
were designed to maintain HTML tag integrity.
Apply a character limit to a string:
Note:
transA()
andtransChoiceA()
can also make use your resulting string lowercase by setting the second or third argument totrue
. The second argument (second fortransA()
, third fortransChoiceA()
) is theparameters
array, but if it is a boolean, theparameters
array will be set to empty and it will be interpreted as thelower
argument instead.