Code Duplication    Length = 38-40 lines in 2 locations

lib/ConfigToken/TreeCompiler.php 2 locations

@@ 621-658 (lines=38) @@
618
            return array();
619
        }
620
621
        if ((!isset($xrefData[$this->includeKey])) || (!is_array($xrefData[$this->includeKey]))) {
622
            switch ($includeType) {
623
                case static::INCLUDE_TYPE_XREF:
624
                    throw new XrefResolverFormatException(
625
                        $xref,
626
                        sprintf(
627
                            "Required to explicitly include the list of Xref keys [\"%s\"] " .
628
                            "but the \"%s\" key is missing from the first level.",
629
                            implode('", "', $includeTypeValue),
630
                            $this->includeKey
631
                        )
632
                    );
633
                case static::INCLUDE_TYPE_GROUP:
634
                    if (!$mustIncludeSpecificGroup) {
635
                        if (isset($xrefData[$this->addKey])) {
636
                            $result = $xrefData[$this->addKey];
637
                        } else {
638
                            if (isset($xrefData[$this->removeKey])) {
639
                                unset($xrefData[$this->removeKey]);
640
                            }
641
                            $result = $xrefData;
642
                        }
643
                        if (isset($tokenResolvers)) {
644
                            $tokenResolvers->applyToArray($result);
645
                        }
646
                        return $result;
647
                    }
648
                    throw new XrefResolverFormatException(
649
                        $xref,
650
                        sprintf(
651
                            "Required to explicitly include the \"%s\" group of Xref keys " .
652
                            "but the \"%s\" key is missing from the first level.",
653
                            $includeTypeValue,
654
                            $this->includeKey
655
                        )
656
                    );
657
            }
658
        }
659
        $xrefDataInclude = &$xrefData[$this->includeKey];
660
661
        if ((!isset($xrefDataInclude[$this->includeXrefKey])) || (!is_array($xrefDataInclude[$this->includeXrefKey]))) {
@@ 661-700 (lines=40) @@
658
        }
659
        $xrefDataInclude = &$xrefData[$this->includeKey];
660
661
        if ((!isset($xrefDataInclude[$this->includeXrefKey])) || (!is_array($xrefDataInclude[$this->includeXrefKey]))) {
662
            switch ($includeType) {
663
                case static::INCLUDE_TYPE_XREF:
664
                    throw new XrefResolverFormatException(
665
                        $xref,
666
                        sprintf(
667
                            "Required to explicitly include the list of Xref keys [\"%s\"] " .
668
                            "but the \"%s\" key is missing from the \"%s\" key on the first level.",
669
                            implode('", "', $includeTypeValue),
670
                            $this->includeXrefKey,
671
                            $this->includeKey
672
                        )
673
                    );
674
                case static::INCLUDE_TYPE_GROUP:
675
                    if (!$mustIncludeSpecificGroup) {
676
                        if (isset($xrefData[$this->addKey])) {
677
                            $result = $xrefData[$this->addKey];
678
                        } else {
679
                            if (isset($xrefData[$this->removeKey])) {
680
                                unset($xrefData[$this->removeKey]);
681
                            }
682
                            $result = $xrefData;
683
                        }
684
                        if (isset($tokenResolvers)) {
685
                            $tokenResolvers->applyToArray($result);
686
                        }
687
                        return $result;
688
                    }
689
                    throw new XrefResolverFormatException(
690
                        $xref,
691
                        sprintf(
692
                            "Required to explicitly include the \"%s\" group of Xref keys " .
693
                            "but the \"%s\" key is missing from the \"%s\" key on the first level.",
694
                            $includeTypeValue,
695
                            $this->includeXrefKey,
696
                            $this->includeKey
697
                        )
698
                    );
699
            }
700
        }
701
        $xrefDataIncludeXrefs = &$xrefDataInclude[$this->includeXrefKey];
702
703
        $xrefKeysToBeResolved = $this->getXrefKeysToBeResolved(