Configuration

The mapper class constructor takes an optional options object MapperConfig that allows to change a few ways the mapper behaves. If no object is passed, the default values will be used as found bellow.

OptionTypeDefaultDescription
allowUninitializedFieldsbooltrueIf disabled, the mapper will fail if one of the class properties that does not have a default value was not present in the data array.
classCacheKeySourcestringfqcnConfigures what hashing data is used to create the cache file for the classes. fqcn uses the fully-qualified class name, md5 uses an md5 hash of the file content and modified uses the last modified date from the class file.
classMapperDirectorystring/tmp/mappersThis is the location the mapper will create cached mapper functions for objects.
The default location is a mappers function in the operating system temporary folder.
debugboolfalseEnabling debug will clear all cached mapper functions after mapping has completed.
enumTryFromboolfalseEnabling this will use the ::tryFrom() method instead of ::from() to parse strings to enums.
nullObjectFromEmptyArrayboolfalseIf enabled, an empty array will be mapped to null value if the object type is nullable.
strictNullMappingbooltrueIf enabled, the mapper will throw an error when a null value is passed for a property that was not typed as nullable.