@@ -281,11 +281,14 @@ private static function validateConfiguration(array $config): void
281281 {
282282 // Validate 'max_pool_size'
283283 if (isset ($ config ['max_pool_size ' ])) {
284- if (!is_int ($ config ['max_pool_size ' ]) || $ config [ ' max_pool_size ' ] <= 0 ) {
284+ if (!is_int ($ config ['max_pool_size ' ])) {
285285 throw new \InvalidArgumentException (
286- "'max_pool_size' must be a positive integer, got: " . gettype ($ config ['max_pool_size ' ])
286+ "'max_pool_size' must be an integer, got: " . gettype ($ config ['max_pool_size ' ])
287287 );
288288 }
289+ if ($ config ['max_pool_size ' ] <= 0 ) {
290+ throw new \InvalidArgumentException ("'max_pool_size' must be a positive integer " );
291+ }
289292 if ($ config ['max_pool_size ' ] > 1000 ) {
290293 throw new \InvalidArgumentException (
291294 "'max_pool_size' cannot exceed 1000 for memory safety, got: {$ config ['max_pool_size ' ]}"
@@ -295,11 +298,14 @@ private static function validateConfiguration(array $config): void
295298
296299 // Validate 'default_capacity'
297300 if (isset ($ config ['default_capacity ' ])) {
298- if (!is_int ($ config ['default_capacity ' ]) || $ config [ ' default_capacity ' ] <= 0 ) {
301+ if (!is_int ($ config ['default_capacity ' ])) {
299302 throw new \InvalidArgumentException (
300- "'default_capacity' must be a positive integer, got: " . gettype ($ config ['default_capacity ' ])
303+ "'default_capacity' must be an integer, got: " . gettype ($ config ['default_capacity ' ])
301304 );
302305 }
306+ if ($ config ['default_capacity ' ] <= 0 ) {
307+ throw new \InvalidArgumentException ("'default_capacity' must be a positive integer " );
308+ }
303309 if ($ config ['default_capacity ' ] > 1024 * 1024 ) { // 1MB limit
304310 throw new \InvalidArgumentException (
305311 "'default_capacity' cannot exceed 1MB (1048576 bytes), got: {$ config ['default_capacity ' ]}"
@@ -324,9 +330,14 @@ private static function validateConfiguration(array $config): void
324330 throw new \InvalidArgumentException ("Size category names must be non-empty strings " );
325331 }
326332
327- if (!is_int ($ capacity ) || $ capacity <= 0 ) {
333+ if (!is_int ($ capacity )) {
334+ throw new \InvalidArgumentException (
335+ "Size category ' {$ name }' must have an integer capacity, got: " . gettype ($ capacity )
336+ );
337+ }
338+ if ($ capacity <= 0 ) {
328339 throw new \InvalidArgumentException (
329- "Size category ' {$ name }' must have a positive integer capacity, got: " . gettype ( $ capacity )
340+ "Size category ' {$ name }' must have a positive integer capacity "
330341 );
331342 }
332343
0 commit comments