@@ -89,20 +89,17 @@ public function reverseTransform($value)
89
89
if (!is_string ($ value )) {
90
90
throw new TransformationFailedException ('Expected a string. ' );
91
91
}
92
+ if (!$ this ->isISO8601 ($ value )) {
93
+ throw new TransformationFailedException ('Non ISO 8601 date strings are not supported yet ' );
94
+ }
95
+ $ valuePattern = '/^ ' .preg_replace ('/%([yYmMdDhHiIsSwW])(\w)/ ' , '(?P<$1>\d+)$2 ' , $ this ->format ).'$/ ' ;
96
+ if (!preg_match ($ valuePattern , $ value )) {
97
+ throw new TransformationFailedException (
98
+ sprintf ('Value "%s" contains intervals not accepted by format "%s". ' , $ value , $ this ->format )
99
+ );
100
+ }
92
101
try {
93
- if ($ this ->isISO8601 ($ value )) {
94
- $ valuePattern = '/^ ' .preg_replace ('/%([yYmMdDhHiIsSwW])(\w)/ ' , '(?P<$1>\d+)$2 ' , $ this ->format ).'$/ ' ;
95
- if (!preg_match ($ valuePattern , $ value )) {
96
- throw new TransformationFailedException (
97
- sprintf ('Value "%s" contains intervals not accepted by format "%s". ' , $ value , $ this ->format )
98
- );
99
- }
100
- $ dateInterval = new \DateInterval ($ value );
101
- } else {
102
- throw new TransformationFailedException ('Non ISO 8601 date strings are not supported yet ' );
103
- }
104
- } catch (TransformationFailedException $ e ) {
105
- throw $ e ;
102
+ $ dateInterval = new \DateInterval ($ value );
106
103
} catch (\Exception $ e ) {
107
104
throw new TransformationFailedException ($ e ->getMessage (), $ e ->getCode (), $ e );
108
105
}
0 commit comments