@@ -438,6 +438,8 @@ private function stripAndReturnParameters($reference)
438
438
* @param string $inputString
439
439
* @return string | null
440
440
* @throws \Exception
441
+ *
442
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
441
443
*/
442
444
private function findAndReplaceReferences ($ objectHandler , $ inputString )
443
445
{
@@ -460,25 +462,24 @@ private function findAndReplaceReferences($objectHandler, $inputString)
460
462
continue ;
461
463
}
462
464
463
- // specify behavior depending on field
464
- switch (get_class ($ obj )) {
465
- case PageObject::class:
466
- $ this ->validateUrlAreaAgainstActionType ($ obj );
467
- $ replacement = $ obj ->getUrl ();
468
- $ parameterized = $ obj ->isParameterized ();
469
- break ;
470
- case SectionObject::class:
471
- list (,$ objField ) = $ this ->stripAndSplitReference ($ match );
472
- if ($ obj ->getElement ($ objField ) == null ) {
473
- throw new TestReferenceException ("Could not resolve entity reference " . $ inputString );
474
- }
475
- $ parameterized = $ obj ->getElement ($ objField )->isParameterized ();
476
- $ replacement = $ obj ->getElement ($ objField )->getPrioritizedSelector ();
477
- $ this ->setTimeout ($ obj ->getElement ($ objField )->getTimeout ());
478
- break ;
479
- case EntityDataObject::class:
480
- $ replacement = $ this ->resolveEntityDataObjectReference ($ obj , $ match );
481
- break ;
465
+ if ($ obj == null ) {
466
+ // keep initial values for subsequent logic
467
+ $ replacement = null ;
468
+ $ parameterized = false ;
469
+ } elseif (get_class ($ obj ) == PageObject::class) {
470
+ $ this ->validateUrlAreaAgainstActionType ($ obj );
471
+ $ replacement = $ obj ->getUrl ();
472
+ $ parameterized = $ obj ->isParameterized ();
473
+ } elseif (get_class ($ obj ) == SectionObject::class) {
474
+ list (,$ objField ) = $ this ->stripAndSplitReference ($ match );
475
+ if ($ obj ->getElement ($ objField ) == null ) {
476
+ throw new TestReferenceException ("Could not resolve entity reference " . $ inputString );
477
+ }
478
+ $ parameterized = $ obj ->getElement ($ objField )->isParameterized ();
479
+ $ replacement = $ obj ->getElement ($ objField )->getPrioritizedSelector ();
480
+ $ this ->setTimeout ($ obj ->getElement ($ objField )->getTimeout ());
481
+ } elseif (get_class ($ obj ) == EntityDataObject::class) {
482
+ $ replacement = $ this ->resolveEntityDataObjectReference ($ obj , $ match );
482
483
}
483
484
484
485
if ($ replacement == null ) {
0 commit comments