Code Duplication    Length = 15-19 lines in 2 locations

src/string/AbstractCG.php 1 location

@@ 82-96 (lines=15) @@
79
     *
80
     * @return int -1, 0, 1 Lower, equal, higher
81
     */
82
    public function compare(AbstractCG $group): int
83
    {
84
        // Equal character group types - return length comparison
85
        if ($this->isSameType($group)) {
86
            // Variable character groups with longer length has higher priority
87
            return $this->compareLength($group);
88
        }
89
90
        /**
91
         * Character groups are different:
92
         * Fixed character groups has higher priority,
93
         * variable character groups has lower priority
94
         */
95
        return $this->isFixed() ? 1 : -1;
96
    }
97
98
    /**
99
     * Check if compared character group has same type.

src/string/VariableFixedCG.php 1 location

@@ 54-72 (lines=19) @@
51
    /**
52
     * @inheritdoc
53
     */
54
    public function compare(AbstractCG $group): int
55
    {
56
        // Equal character group types - return length comparison
57
        if ($this->isSameType($group)) {
58
            // Variable character groups with longer length has higher priority
59
            return $this->compareLength($group);
60
        }
61
62
        // Fixed character group has higher priority
63
        if ($group->isFixed()) {
64
            return -1;
65
        }
66
67
        /**
68
         * VariableFixed character group has higher priority than regular
69
         * variable character group.
70
         */
71
        return 1;
72
    }
73
74
    /**
75
     * @inheritdoc