Code Duplication    Length = 13-13 lines in 2 locations

src/Builder/InsertOnDuplicateKeyBuilder.php 1 location

@@ 43-55 (lines=13) @@
40
                return true;
41
            }
42
43
            if (!\is_array(reset($values))) {
44
                $values = [$values];
45
            }
46
47
            // Here, we will sort the insert keys for every record so that each insert is
48
            // in the same order for the record. We need to make sure this is the case
49
            // so there are not any errors or problems when inserting these records.
50
            else {
51
                foreach ($values as $key => $value) {
52
                    ksort($value);
53
                    $values[$key] = $value;
54
                }
55
            }
56
            // Finally, we will run this query against the database connection and return
57
            // the results. We will need to also flatten these bindings before running
58
            // the query so they are all in one huge, flattened array for execution.

src/Builder/ReplaceIntoBuilder.php 1 location

@@ 29-41 (lines=13) @@
26
            // Since every insert gets treated like a batch insert, we will make sure the
27
            // bindings are structured in a way that is convenient for building these
28
            // inserts statements by verifying the elements are actually an array.
29
            if (!\is_array(reset($values))) {
30
                $values = [$values];
31
            }
32
33
            // Since every insert gets treated like a batch insert, we will make sure the
34
            // bindings are structured in a way that is convenient for building these
35
            // inserts statements by verifying the elements are actually an array.
36
            else {
37
                foreach ($values as $key => $value) {
38
                    ksort($value);
39
                    $values[$key] = $value;
40
                }
41
            }
42
            // We'll treat every insert like a batch insert so we can easily insert each
43
            // of the records into the database consistently. This will make it much
44
            // easier on the grammars to just handle one type of record insertion.