plain-to-class v1

This hydrator transforms your data into a typed object.

Overview

This package will help you transform any dataset into a structured object. This is very convenient when values obtained from a query, database, or any other place can be easily cast to the object you need.

When writing code, it is very important to separate logic, adhere to the principle of single responsibility, reduce dependence on other services, and much more.

When creating a new service to create a user, you only need the necessary data set — name, email and phone. Why do you need to check around separately arrays, separately objects, check for the presence of keys through isset. It is much more convenient to make a DTO model with which the service will already work.

This approach guarantees that the service will work with the data it needs, full typing, there is no need to check for the presence of keys if it is an array.