1. Go to this page and download the library: Download dashifen/transformer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dashifen / transformer example snippets
class Transformer extends AbstractTransformer {
protected function getTransformationMethod(string $field): string {
// to convert a kebab-case $field to a function name, we want to
// convert it to StudlyCaps. so, first, we convert from kebab-case to
// camelCase and then we ucfirst() the camelCase string to make it
// studly. finally, we add the word "transform." Thus, a start-date
// field becomes startDate, then StartDate, and finally we return
// transformStartDate.
$camelCase = preg_replace_callback("/-([a-z])/", function (array $matches): string {
return strtoupper($matches[1]);
}, $field);
return "transform" . ucfirst($camelCase);
}
private function transformStartDate(string $date): string {
// we assume that $date has already been validated, so here we just
// want to make sure it's in YYYY-MM-DD format. strtotime() can help
// with that!
return date("Y-m-d", strtotime($date));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.