Code Duplication    Length = 40-43 lines in 2 locations

app/Http/Controllers/Scoring.php 2 locations

@@ 55-97 (lines=43) @@
52
        ]);
53
    }
54
55
    public function checkFullRow(): void
56
    {
57
        // LOOP FOR EACH ROW
58
        for ($row = 0; $row < 5; $row++) {
59
            for ($column = 0; $column < 5; $column++) {
60
                $this->notScoredYet = true;
61
                // initial length is 0, if not then session contians card
62
                // ROW SUITS AND VALUES
63
                // if a card is existing (form length has 235)
64
                $this->currentSession = session('grid.' . $row . $column);
65
                if (strlen($this->currentSession) != 235) {
66
                    // collect suit HDSC and value 02-14 for row
67
                    array_push($this->suitsRow, substr($this->currentSession, 23, 1));
68
                    array_push($this->valuesRow, substr($this->currentSession, 21, 2));
69
                }
70
                // ROW SAVE AND SCORE DATA
71
                // if five cards (five suits), push suits and values arrays
72
                if ($column == 4 && count($this->suitsRow) == 5) {
73
                    // session('dataRow00', [[H,D,C,S,D],[03,05,01,13,10]])
74
                    session()->push('dataRow' . $row, $this->suitsRow);
75
                    session()->push('dataRow' . $row, $this->valuesRow);
76
                    // send array of suits and values for row to score function
77
                    $this->sortHand('Row' . $row);
78
                    // when match is found, $this->notScoredYet = false and rest of functions will not proceed
79
                    $this->scoreSameSuit('Row' . $row);
80
                    $this->checkValueOccurrence('Row' . $row);
81
                    $this->fourOfaKind('Row' . $row);
82
                    $this->fullHouse('Row' . $row);
83
                    $this->threeOfAKind('Row' . $row);
84
                    $this->twoPairsOrPair('Row' . $row);
85
                    $this->straightOrNothing('Row' . $row);
86
87
                    // before next loop, reset to false
88
                    $this->setNotScoredYetBackToFalse();
89
                }
90
                // reset suits and values before next column
91
                if ($column == 4) {
92
                    $this->suitsRow = [];
93
                    $this->valuesRow = [];
94
                }
95
            }
96
        }
97
    }
98
99
    public function checkFullColumn(): void
100
    {
@@ 99-138 (lines=40) @@
96
        }
97
    }
98
99
    public function checkFullColumn(): void
100
    {
101
        // LOOP FOR EACH COLUMN
102
        for ($column = 0; $column < 5; $column++) {
103
            for ($row = 0; $row < 5; $row++) {
104
                $this->notScoredYet = true;
105
                // ROW SUITS AND VALUES
106
                // if a card is existing (form length has 233)
107
                $this->currentSession = session('grid.' . $row . $column);
108
                if (strlen($this->currentSession) != 235) {
109
                    // collect suit HDSC and value 02-14 for column
110
                    array_push($this->suitsColumn, substr($this->currentSession, 23, 1));
111
                    array_push($this->valuesColumn, substr($this->currentSession, 21, 2));
112
                }
113
                // COLUMN SAVE AND SCORE DATA
114
                if ($row == 4 && count($this->suitsColumn) == 5) {
115
                    session()->push('dataColumn' . $column, $this->suitsColumn);
116
                    session()->push('dataColumn' . $column, $this->valuesColumn);
117
118
                    //begin with sorting hand and set
119
                    $this->sortHand('Column' . $column);
120
                    // when match is found, $this->notScoredYet = false and rest of functions will not proceed
121
                    $this->scoreSameSuit('Column' . $column);
122
                    $this->checkValueOccurrence('Column' . $column);
123
                    $this->fourOfaKind('Column' . $column);
124
                    $this->fullHouse('Column' . $column);
125
                    $this->threeOfAKind('Column' . $column);
126
                    $this->twoPairsOrPair('Column' . $column);
127
                    $this->straightOrNothing('Column' . $column);
128
                    // before next loop, reset to false
129
                    $this->setNotScoredYetBackToFalse();
130
                }
131
                // reset suits and values before next column
132
                if ($row == 4) {
133
                    $this->suitsColumn = [];
134
                    $this->valuesColumn = [];
135
                }
136
            }
137
        }
138
    }
139
140
    public function sortHand($type)
141
    {