You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finally, to get your object back you will have to call the `map` method as show below:
169
+
170
+
```php
171
+
$csv = Reader::createFromString($document);
172
+
$csv->setHeaderOffset(0);
173
+
foreach ($csv->map(Weather::class) as $weather) {
174
+
// each $weather entry will be an instance of the Weather class;
175
+
}
176
+
```
177
+
178
+
The `Column` attribute is responsible to link the record cell via its numeric or name offset and will
179
+
tell the mapper how to type cast the cell value to the DTO property. By default, if no casting
180
+
rule is provided, the column will attempt to cast the cell value to the scalar type of
181
+
the property. If type casting fails or is not possible, an exception will be thrown.
182
+
183
+
The library comes bundles with 3 type casting classes which relies on the property type information:
184
+
185
+
-`CastToScalar`: converts the cell value to a scalar type or `null` depending on the property type information.
186
+
-`CastToDate`: converts the cell value into a PHP `DateTimeInterface` implementing object. You can optionally specify the date format and its timezone if needed.
187
+
-`CastToEnum`: converts the cell vale into a PHP `Enum` backed or not.
188
+
189
+
You can also provide your own class to typecast the cell value according to your own rules. To do so, first,
0 commit comments