/**
  * {@inheritdoc}
  */
 public function transform($json)
 {
     if (!$this->validatorChain->isValid($json)) {
         throw new TransformationFailedException('None of the chained validators were able to validate the data!');
     }
     /** @var PackageInterface $package */
     $package = $this->serializer->deserialize($json, Package::class, 'json');
     /** @var ItemInterface $item */
     foreach ($package->getItems()->toArray() as $item) {
         $item->setPackage($package);
     }
     return $package;
 }
 public function it_should_throw_exception(ValidatorInterface $validator)
 {
     $validator->isValid('{invalid json}')->willReturn(false);
     $this->shouldThrow(TransformationFailedException::class)->during('transform', ['{invalid json}']);
 }