Skip to content

Commit

Permalink
add ArrayConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
nsd0mnawabee committed Aug 20, 2024
1 parent 91a1da3 commit aeae45d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Converter/ArrayConverter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Neusta\ConverterBundle\Converter;

use Neusta\ConverterBundle\Converter;
use Neusta\ConverterBundle\Exception\ConverterException;

class ArrayConverter
{
public function __construct(private readonly Converter $converter)
{
}

/**
* @param array<mixed> $source
*
* @throws ConverterException
*/
public function convert(array $source, ?object $ctx = null): object
{
$arrayObject = new \ArrayObject($source);

return $this->converter->convert($arrayObject, $ctx);
}
}

0 comments on commit aeae45d

Please sign in to comment.