for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GFG\Mapper\Data;
class Manager
{
private $mapper;
private $factory;
public function __construct(
MapperInterface $mapper,
MapperFactory $factory
) {
$this->mapper = $mapper;
$this->factory = $factory;
}
public function map(array &$data, array $structure)
foreach ($structure as $key => $value) {
$keyData = &$data[$key];
if (!isset($value['prefix'])) {
$this->map($keyData, $value);
} else {
foreach ((array) $value['type'] as $type) {
$type = $this->factory->create($type, $this->mapper, [
'prefix' => $value['prefix'],
'use' => isset($value['use']) ? $value['use'] : ''
]);
$type->run($keyData);