Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 11 |
PostDataFormDataMapper | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
56 | |
0.00% |
0 / 11 |
mapDataToForms | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 7 |
|||
mapFormsToData | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
|||
configureOptions | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
<?php declare(strict_types = 1); | |
// | |
// Generated by Smalldb\CodeCooker\Generator\DtoGenerator. | |
// Do NOT edit! All changes will be lost! | |
// | |
// | |
namespace Smalldb\StateMachine\Test\Example\Post\PostData; | |
use Smalldb\CodeCooker\Annotation\GeneratedClass; | |
use Symfony\Component\Form\DataMapperInterface; | |
use Symfony\Component\Form\Exception\UnexpectedTypeException; | |
use Symfony\Component\OptionsResolver\OptionsResolver; | |
/** | |
* @GeneratedClass | |
* @see \Smalldb\StateMachine\Test\Example\Post\PostProperties | |
*/ | |
class PostDataFormDataMapper implements DataMapperInterface | |
{ | |
public function mapDataToForms($viewData, iterable $forms) | |
{ | |
if ($viewData === null) { | |
return; | |
} else if ($viewData instanceof PostData) { | |
foreach ($forms as $prop => $field) { | |
$field->setData(PostDataImmutable::get($viewData, $prop)); | |
} | |
} else { | |
throw new UnexpectedTypeException($viewData, PostDataImmutable::class); | |
} | |
} | |
public function mapFormsToData(iterable $forms, & $viewData) | |
{ | |
$viewData = PostDataImmutable::fromIterable($viewData, (function() use ($forms) { foreach($forms as $k => $field) yield $k => $field->getData(); })()); | |
} | |
public function configureOptions(OptionsResolver $optionsResolver) | |
{ | |
$optionsResolver->setDefault("empty_data", null); | |
$optionsResolver->setDefault("data_class", PostData::class); | |
} | |
} | |