Code Duplication    Length = 10-12 lines in 2 locations

lib/AbstractViewComponent.php 2 locations

@@ 400-411 (lines=12) @@
397
        
398
        foreach ($inputSpec as $fieldName => $fieldSpec) {
399
            // Required field
400
            if (( count( $fieldSpec ) < 2 )) {
401
                if (!isset( $inputs[ $fieldName ] )) {
402
                    $calledFunc = debug_backtrace()[1]['function'];
403
                    $callerFunc = debug_backtrace()[2]['function'];
404
                    $callerClass = debug_backtrace()[2]['class'];
405
                    $parentText = '';
406
                    if( $this->parent !== null ){
407
                        $parentText = " (parent component is ".get_class($this->parent).")";
408
                    }
409
                    throw new \Exception( $fieldName . " is a required field for " . get_class( $this )."::{$calledFunc}() called from {$callerClass}::{$callerFunc}(){$parentText}" );
410
                }
411
            }
412
            // Set default is unset
413
            if (!isset( $inputs[ $fieldName ] )) {
414
                $inputs[ $fieldName ] = $fieldSpec[ 1 ];
@@ 459-468 (lines=10) @@
456
                    default:
457
                        $failed = !( $input instanceof $requiredType );
458
                }
459
                if ($failed) {
460
                    $calledFunc = debug_backtrace()[1]['function'];
461
                    $callerFunc = debug_backtrace()[2]['function'];
462
                    $callerClass = debug_backtrace()[2]['class'];
463
                    $parentText = '';
464
                    if( $this->parent !== null ){
465
                        $parentText = " (parent component is ".get_class($this->parent).")";
466
                    }
467
                    throw new \Exception( $fieldName . " should be of type " . $requiredType . "in " . get_class( $this )."::{$calledFunc}() called from {$callerClass}::{$callerFunc}(){$parentText}" );
468
                }
469
            }
470
        }
471
    }