Sanitizing and formatting data with the Transformer PHP package

Transformer is a PHP package for sanitizing and formatting data powered by Laravel’s validation components. The package uses a familiar Laravel validation-like syntax to transform data using classes, callable functions and etc.

Here is a quick sample.

$input = [
  'name' => '  yuuma  ',
  'phone_number' => '123-4567-7891',
  'date_of_birth' => "1998-04-12",
];

(new DataTransformer($input, [
    'name' => 'trim|ucfirst',
    'phone_number' => 'only_numbers',
    'date_of_birth' => 'to_carbon|->format:m/d/y',
]))->transform();

// Returns:
// [
//     "name" => "Yuuma",
//     "phone_number" => "12345677891",
//     "date_of_birth" => "04/12/98",
// ]

Data can also be transformed using closures or classes that implement the provided Transformable interface. Additionally, this package supports nested array data using dot notation, wildcard input (applying functions to keys matching a wildcard pattern), and more.

Learn more about this package, get full installation instructions, and view the source code on GitHub.

Yuuma



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム