@@ -311,6 +311,8 @@ $value = $data->getRequiredArrayGetter('key');
311311
312312### Get SimpleXMLElement
313313
314+ > Since v0.6.0
315+
314316Return SimpleXMLElement for given key. Uses ` xml ` transformer strategy.
315317
316318``` php
@@ -319,7 +321,8 @@ $xml = $data->getNullableXML('child');
319321
320322### GetValue with XMLData
321323
322- > Throws always ` NotXMLException ` exception if value is not a SimpleXMLElement. XML transformer strategy is applied.
324+ > Since v0.6.0. Throws always ` NotXMLException ` exception if value is not a SimpleXMLElement. XML transformer strategy
325+ > is applied.
323326
324327Get always ` GetValue ` instance even if provided data is missing or if null.
325328
@@ -342,7 +345,8 @@ $value = $data->getRequiredXMLGetter('key');
342345
343346### GetValue XML attributes
344347
345- > Throws always ` NotXMLException ` exception if value is not a SimpleXMLElement. XML transformer strategy is applied.
348+ > Since v0.6.0. Throws always ` NotXMLException ` exception if value is not a SimpleXMLElement. XML transformer strategy
349+ > is applied.
346350
347351Wraps XML element attributes in GetValue instance (even if attributes are not set in element).
348352
@@ -358,6 +362,51 @@ $attributes = $data->getXMLAttributesGetter('node');
358362$attributes->getString('attributeName');
359363```
360364
365+ ### GetObject
366+
367+ > Since v0.6.1
368+
369+ - Allows getting object of specified type.
370+ - You can transform raw value to expected object by using transformers (with ` GetterTransformer ` )
371+
372+ ``` php
373+ use Wrkflow\GetValue\Contracts\GetValueTransformerContract;
374+ use Wrkflow\GetValue\GetValue;
375+ use Wrkflow\GetValue\DataHolders\ArrayData;
376+ use Wrkflow\GetValue\Transformers\GetterTransformer;
377+
378+ $data = new GetValue(new ArrayData([
379+ 'person' => ['name' => 'Marco', 'surname' => 'Polo'],
380+ ]));
381+
382+ class PersonEntity
383+ {
384+ public function __construct(
385+ public readonly string $firstName,
386+ public readonly string $lastName,
387+ ) {
388+ }
389+ }
390+
391+ class TestEntityTransformer implements GetValueTransformerContract
392+ {
393+ public function transform(GetValue $value, string $key): PersonEntity
394+ {
395+ return new PersonEntity(
396+ firstName: $value->getRequiredString('name'),
397+ lastName: $value->getRequiredString('surname'),
398+ );
399+ }
400+ }
401+
402+ $person = $this->data->getObject(
403+ Person::class,
404+ 'person',
405+ new PersonTransformer()
406+ );
407+ // PersonEntity{firstName=Marco,lastName=Polo}
408+ ```
409+
361410## Exceptions
362411
363412> All exceptions receive full key that was used for getting data. You can receive it by using ` $exception->getKey() `
0 commit comments