transformable

Zerotoprod\Transformable

Repo GitHub Actions Workflow Status Packagist Downloads Packagist Version GitHub repo size License

Transform a class into different types.

Installation

You can install the package via Composer:

composer require zerotoprod/transformable

Additional Packages

Methods

Usage

To use the Zerotoprod\Transformable\Transformable trait in your class, simply include it:

use Zerotoprod\Transformable\Transformable;

class YourDataModel
{
    use Transformable;

    public $name;
    public $email;
}

$model = new YourDataModel();
$model->name = 'John Doe';
$model->email = 'john.doe@example.com';

$array = $model->toArray();
$json = $model->toJson();