Ejemplo n.º 1
0
 private function handle(ClassType $type, $value, $expectedTransformed = null)
 {
     $transformer = new TypedObjectTransformer(TransformerRegistryRepository::getDefaultTransformerRegistry(), new TypeFactory());
     $transformed = $transformer->transform(new TypedValue($value, $type));
     if ($expectedTransformed !== null) {
         $this->assert->equals($transformed, $expectedTransformed);
     }
     $this->assert->equals($transformer->revert(new TypedValue($transformed, $type)), $value);
 }
 private function handle($value, $expectedTransformed = null)
 {
     $registry = TransformerRegistryRepository::getDefaultTransformerRegistry();
     $transformed = $registry->toTransform($value)->transform($value);
     if ($expectedTransformed !== null) {
         $this->assert->equals($transformed, $expectedTransformed);
     }
     $reverted = $registry->toRevert($transformed)->revert($transformed);
     $this->assert->equals($value, $reverted);
 }
Ejemplo n.º 3
0
 /**
  * @param null|Type $type
  * @param null|TransformerRegistry $transformers
  * @param null|Serializer $serializer
  */
 public function __construct(Type $type = null, TransformerRegistry $transformers = null, Serializer $serializer = null)
 {
     $this->type = $type ?: new UnknownType();
     $this->transformers = $transformers ?: TransformerRegistryRepository::getDefaultTransformerRegistry();
     $this->serializer = $serializer ?: SerializerRepository::getDefault();
 }