This repository was archived by the owner on Jan 31, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -90,15 +90,17 @@ public function __construct($options = null)
90
90
$ options = $ temp ;
91
91
}
92
92
93
- if (count ($ options ) !== 2
94
- && (! array_key_exists ('min ' , $ options ) || ! array_key_exists ('max ' , $ options ))
95
- ) {
93
+ if (! array_key_exists ('min ' , $ options ) || ! array_key_exists ('max ' , $ options )) {
96
94
throw new Exception \InvalidArgumentException ("Missing option: 'min' and 'max' have to be given " );
97
95
}
98
96
99
- if (is_numeric ($ options ['min ' ]) && is_numeric ($ options ['max ' ])) {
97
+ if ((isset ($ options ['min ' ]) && is_numeric ($ options ['min ' ]))
98
+ && (isset ($ options ['max ' ]) && is_numeric ($ options ['max ' ]))
99
+ ) {
100
100
$ this ->numeric = true ;
101
- } elseif (is_string ($ options ['min ' ]) && is_string ($ options ['max ' ])) {
101
+ } elseif ((isset ($ options ['min ' ]) && is_string ($ options ['min ' ]))
102
+ && (isset ($ options ['max ' ]) && is_string ($ options ['max ' ]))
103
+ ) {
102
104
$ this ->numeric = false ;
103
105
} else {
104
106
throw new Exception \InvalidArgumentException (
Original file line number Diff line number Diff line change @@ -265,12 +265,13 @@ public function testMissingMinOrMax(array $args)
265
265
public function constructBetweenValidatorInvalidDataProvider ()
266
266
{
267
267
return [
268
- [
269
- ['min ' => 1 ],
270
- ],
271
- [
272
- ['max ' => 5 ],
273
- ],
268
+ 'only-min ' => [['min ' => 1 ]],
269
+ 'only-max ' => [['max ' => 5 ]],
270
+ 'min-inclusive ' => [['min ' => 0 , 'inclusive ' => true ]],
271
+ 'max-inclusive ' => [['max ' => 5 , 'inclusive ' => true ]],
272
+ 'min-undefined ' => [['min ' => 0 , 'foo ' => 'bar ' ]],
273
+ 'max-undefined ' => [['max ' => 5 , 'foo ' => 'bar ' ]],
274
+ 'no-min-or-max ' => [['bar ' => 'foo ' , 'foo ' => 'bar ' ]],
274
275
];
275
276
}
276
277
You can’t perform that action at this time.
0 commit comments