File tree Expand file tree Collapse file tree
src/ZipCodeValidator/Constraints Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,13 @@ public function __construct(
3333 )
3434 {
3535 if (is_string ($ options )) {
36+ if (null !== $ iso ) {
37+ throw new InvalidOptionsException (
38+ 'Cannot pass both positional string $options and named "iso". Use one style. ' ,
39+ ['options ' , 'iso ' ]
40+ );
41+ }
42+
3643 $ options = ['iso ' => $ options ];
3744 } elseif (null === $ options ) {
3845 $ options = [];
Original file line number Diff line number Diff line change @@ -76,4 +76,10 @@ public function testUnknownLegacyOptionThrowsException(): void
7676 $ this ->expectException (InvalidOptionsException::class);
7777 new ZipCode (['foo ' => 'bar ' , 'iso ' => 'FR ' ]);
7878 }
79+
80+ public function testLegacyStringOptionCannotBeCombinedWithNamedIso (): void
81+ {
82+ $ this ->expectException (InvalidOptionsException::class);
83+ new ZipCode ('DE ' , iso: 'FR ' );
84+ }
7985}
You can’t perform that action at this time.
0 commit comments