@@ -36,7 +36,7 @@ class ApiPayloadResponse
3636 /** @var bool */
3737 protected $ test ;
3838
39- /** @var array */
39+ /** @var string */
4040 protected $ successDefinition ;
4141
4242 /** @var bool */
@@ -392,10 +392,14 @@ public function validate()
392392 );
393393 }
394394
395- // Always consider a 500 to be an error.
396- if (isset ($ this ->responseActual ['status ' ]) && 500 == $ this ->responseActual ['status ' ]) {
395+ // Always consider a 5xx to be an error.
396+ if (
397+ is_int ($ this ->responseActual ['status ' ])
398+ && $ this ->responseActual ['status ' ] >= 500
399+ && $ this ->responseActual ['status ' ] < 600
400+ ) {
397401 throw new ContactClientException (
398- 'Client responded with a 500 server error code. ' ,
402+ 'Client responded with a ' . $ this -> responseActual [ ' status ' ]. ' server error code. ' ,
399403 0 ,
400404 null ,
401405 Stat::TYPE_ERROR ,
@@ -404,7 +408,7 @@ public function validate()
404408 }
405409
406410 // If there is no success definition, than do the default test of a 200 ok status check.
407- if (! $ this ->successDefinition ) {
411+ if (empty ( $ this ->successDefinition ) || in_array ( $ this -> successDefinition , [ ' null ' , ' [] ' ]) ) {
408412 if (!$ this ->responseActual ['status ' ] || 200 != $ this ->responseActual ['status ' ]) {
409413 throw new ContactClientException (
410414 'Status code is not 200. Default validation failure. ' ,
@@ -414,9 +418,7 @@ public function validate()
414418 true
415419 );
416420 }
417- }
418-
419- if (!empty ($ this ->successDefinition ) && 'null ' !== $ this ->successDefinition ) {
421+ } else {
420422 // Standard success definition validation.
421423 $ filter = new FilterHelper ();
422424 try {
0 commit comments