Code Duplication    Length = 38-40 lines in 2 locations

lib/ConfigToken/TreeCompiler.php 2 locations

@@ 643-680 (lines=38) @@
640
            return array();
641
        }
642
643
        if ((!isset($xrefData[$this->includeKey])) || (!is_array($xrefData[$this->includeKey]))) {
644
            switch ($includeType) {
645
                case static::INCLUDE_TYPE_XREF:
646
                    throw new XrefResolverFormatException(
647
                        $xref,
648
                        sprintf(
649
                            "Required to explicitly include the list of Xref keys [\"%s\"] " .
650
                            "but the \"%s\" key is missing from the first level.",
651
                            implode('", "', $includeTypeValue),
652
                            $this->includeKey
653
                        )
654
                    );
655
                case static::INCLUDE_TYPE_GROUP:
656
                    if (!$mustIncludeSpecificGroup) {
657
                        if (isset($xrefData[$this->addKey])) {
658
                            $result = $xrefData[$this->addKey];
659
                        } else {
660
                            if (isset($xrefData[$this->removeKey])) {
661
                                unset($xrefData[$this->removeKey]);
662
                            }
663
                            $result = $xrefData;
664
                        }
665
                        if (isset($tokenResolvers)) {
666
                            $tokenResolvers->applyToArray($result);
667
                        }
668
                        return $result;
669
                    }
670
                    throw new XrefResolverFormatException(
671
                        $xref,
672
                        sprintf(
673
                            "Required to explicitly include the \"%s\" group of Xref keys " .
674
                            "but the \"%s\" key is missing from the first level.",
675
                            $includeTypeValue,
676
                            $this->includeKey
677
                        )
678
                    );
679
            }
680
        }
681
        $xrefDataInclude = &$xrefData[$this->includeKey];
682
683
        if ((!isset($xrefDataInclude[$this->includeXrefKey])) || (!is_array($xrefDataInclude[$this->includeXrefKey]))) {
@@ 683-722 (lines=40) @@
680
        }
681
        $xrefDataInclude = &$xrefData[$this->includeKey];
682
683
        if ((!isset($xrefDataInclude[$this->includeXrefKey])) || (!is_array($xrefDataInclude[$this->includeXrefKey]))) {
684
            switch ($includeType) {
685
                case static::INCLUDE_TYPE_XREF:
686
                    throw new XrefResolverFormatException(
687
                        $xref,
688
                        sprintf(
689
                            "Required to explicitly include the list of Xref keys [\"%s\"] " .
690
                            "but the \"%s\" key is missing from the \"%s\" key on the first level.",
691
                            implode('", "', $includeTypeValue),
692
                            $this->includeXrefKey,
693
                            $this->includeKey
694
                        )
695
                    );
696
                case static::INCLUDE_TYPE_GROUP:
697
                    if (!$mustIncludeSpecificGroup) {
698
                        if (isset($xrefData[$this->addKey])) {
699
                            $result = $xrefData[$this->addKey];
700
                        } else {
701
                            if (isset($xrefData[$this->removeKey])) {
702
                                unset($xrefData[$this->removeKey]);
703
                            }
704
                            $result = $xrefData;
705
                        }
706
                        if (isset($tokenResolvers)) {
707
                            $tokenResolvers->applyToArray($result);
708
                        }
709
                        return $result;
710
                    }
711
                    throw new XrefResolverFormatException(
712
                        $xref,
713
                        sprintf(
714
                            "Required to explicitly include the \"%s\" group of Xref keys " .
715
                            "but the \"%s\" key is missing from the \"%s\" key on the first level.",
716
                            $includeTypeValue,
717
                            $this->includeXrefKey,
718
                            $this->includeKey
719
                        )
720
                    );
721
            }
722
        }
723
        $xrefDataIncludeXrefs = &$xrefDataInclude[$this->includeXrefKey];
724
725
        $xrefKeysToBeResolved = $this->getXrefKeysToBeResolved(