/** * Check if number provided respects the pattern of the localizer. * If false, throw an exception. * It true, delocalize localized number to the default format * * @param string $number * * @throws TransformationFailedException * * @return string */ public function reverseTransform($number) { $violations = $this->localizer->validate($number, 'code', $this->options); if (null === $violations || 0 === $violations->count()) { return $this->localizer->delocalize($number, $this->options); } throw new TransformationFailedException($violations->get(0)->getMessage()); }
/** * Convert a localized attribute * * @param LocalizerInterface $localizer * @param array $item * @param array $options * @param string $path * * @return array */ protected function convertToDefaultFormat(LocalizerInterface $localizer, array $item, array $options, $path) { $violations = $localizer->validate($item['data'], $path, $options); if (null !== $violations) { $this->violations->addAll($violations); } $item['data'] = $localizer->delocalize($item['data'], $options); return $item; }