Type Builders
The Type Builder is a factory class that acts as a layer between the type declaration (like non-empty-string) and the type instance (like NonEmptyStringType).
To register types in the Mapper, a platform is used containing a set of type builders that analyze the type description (and AST) and create a set of type instances used directly at runtime for checking and casting values.
To better understand the tasks of the builder, it makes sense to look at the graph illustrating the process of compiling a type when calling $mapper->denormalize(42) that should return int(42) using built-in TypeInterface<int> type
The diagram is quite complex, and it's okay if you don't quite understand the process. The main thing is that it makes sense:
The platform contains a set of type builders and registers them in the repository.
The type builder returns a specific
TypeInterface<T>from the type declaration string (or more precisely, from its Abstract Syntax Tree).
That is, the code of type builder of int<0, 10> looks something like this: