Download the PHP package inetprocess/transformation without Composer
On this page you can find all versions of the php package inetprocess/transformation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download inetprocess/transformation
More information about inetprocess/transformation
Files in inetprocess/transformation
Package transformation
Short Description This library is a wrapper to transforms a string to another string (date format to another format, strings, regexp....
License GPL-2.0
Informations about the package transformation
inetprocess/transformation
Inspired by Respect/Validation, that library transforms an input string (or float / int / bool) to an output string, after applying rules.
The benefit using it is that it a generic wrapper for any kind of transformation. Also it throws Exceptions and allows to chain the transformations.
Usage
It's pretty simple to use. suppose you need to transform a date "31-12-2012" to another format such as "2012-12-31". Just do:
Now if you need to change the format then the Timezone:
Transformation Rules
For now there is only a few rules. I'll add more later, and don't hesitate if you want to contribute.
Callback(string $functionName, [$param1, $param2, ...])
Call any php function on input. The input will be passed as the last argument of the function.
CopyFileToUuid(string $sourceDir, string $destinationDir)
Copy a file with a filename to a UUID generated name. Return the generated UUID. php T::Concat('REF')->transform('1234'); // REF1234 T::Concat('REF', 'AB')->transform('1234'); // REF1234AB
## Date(string $inputFormat, string $outputFormat)
Transforms a date from a format to another.
_See example above_
## Explode(string $delimiter)
Explode a string to an array using a delimiter. Uses `explode` function from PHP.
It returns an array.
## Htmlspecialchars([array $flags, string $encoding, bool $double_encoding])
Encode special chars. Uses `htmlspecialchars` function from PHP.
## HtmlspecialcharsDecode([array $flags])
Decode special chars. Uses `htmlspecialchars_decode` function from PHP.
## Implode(string $delimiter)
Join an array elements to a string. Uses `implode` function from PHP.
## Map(array $mapping)
Try to replace the input with the value in the mapping.
It can also work with an array as input.
Values not found in mapping are return without tranformations
## MimeType([string $root])
Return the MimeType of the file.
The first optional parameter allow to specify a root directory prepend to the filename
## NormalizeURL(string $protocol)
Prepend a default protocol if not present to any url.
## Replace(string $search, string $replace)
Replace a string by another (does the same than str_replace).
## ReplaceRegexp(string $pattern, string $replacement)
Replace a pattern by a replacement (does the same than preg_replace).
## Slugify()
Uses [Cocur\Slugify](https://github.com/cocur/slugify) to Slugify a string.
## SetType()
Uses settype from PHP for type casting.
## SugarCRMMapMultiEnum(array $mapping, [array $options])
Map multiple values from a string or an array
and return a string encoded for database storage of SugarCRM multi enum field.
String are exploded first with the default separator `|`.
You can set the following options
* `separator`: Separator to use to explode input string. Default: `|`
* `from_multi_enum`: If true parse the input string as a SugarCRM multi enum field. Default: `false`
## Timezone(string $inputFormat, string $targetTimezone, [string $currentTimezone])
Change the Timezone of a Date by providing the format, the target Timezone and optionnaly the timezone for the current date.
_See example above_