Code Duplication    Length = 5-7 lines in 13 locations

src/search/indexer/InverseDocumentFrequency.php 1 location

@@ 54-58 (lines=5) @@
51
        }
52
        $stmt->bindValue(':documentCount', $this->documentCount);
53
        $result = $stmt->execute();
54
        if ($result === false) {
55
            $errorInfo = $db->errorInfo();
56
            $errorMsg = $errorInfo[2];
57
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
58
        }
59
    }
60
}

src/search/indexer/TermCount.php 1 location

@@ 95-99 (lines=5) @@
92
    {
93
        $sql .= '(' . implode('),' . PHP_EOL . '(', $values) . ');';
94
        $stmt = $db->prepare($sql);
95
        if ($stmt === false || !$stmt->execute()) {
96
            $errorInfo = $db->errorInfo();
97
            $errorMsg = $errorInfo[2];
98
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
99
        }
100
    }
101
102
    /**

src/search/indexer/TermFieldLengthNorm.php 3 locations

@@ 46-50 (lines=5) @@
43
	  GROUP BY documentPath, field
44
		';
45
        $stmt = $db->prepare($sql);
46
        if ($stmt === false) {
47
            $errorInfo = $db->errorInfo();
48
            $errorMsg = $errorInfo[2];
49
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
50
        }
51
        if (($stmt->execute()) === false) {
52
            $errorInfo = $db->errorInfo();
53
            $errorMsg = $errorInfo[2];
@@ 51-55 (lines=5) @@
48
            $errorMsg = $errorInfo[2];
49
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
50
        }
51
        if (($stmt->execute()) === false) {
52
            $errorInfo = $db->errorInfo();
53
            $errorMsg = $errorInfo[2];
54
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
55
        }
56
        $uniqueFieldsPerDocument = $stmt->fetchAll(\PDO::FETCH_OBJ);
57
        $values = array();
58
        $i = 0;
@@ 83-87 (lines=5) @@
80
        $sql = 'BEGIN TRANSACTION;' . PHP_EOL;
81
        $sql .= implode(PHP_EOL, $values) . PHP_EOL;
82
        $sql .= 'COMMIT;';
83
        if (($db->exec($sql)) === false) {
84
            $errorInfo = $db->errorInfo();
85
            $errorMsg = $errorInfo[2];
86
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
87
        }
88
    }
89
}

src/search/indexer/TermFrequency.php 1 location

@@ 108-112 (lines=5) @@
105
    private function executeStore($sql, $values, $db)
106
    {
107
        $sql .= '(' . implode('),' . PHP_EOL . '(', $values) . ');';
108
        if (!$db->query($sql)) {
109
            $errorInfo = $db->errorInfo();
110
            $errorMsg = $errorInfo[2];
111
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
112
        }
113
    }
114
115
}

src/search/Search.php 1 location

@@ 85-89 (lines=5) @@
82
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
83
        }
84
        $result = $stmt->fetch(\PDO::FETCH_COLUMN);
85
        if (false === $result) {
86
            $errorInfo = $db->errorInfo();
87
            $errorMsg = $errorInfo[2];
88
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
89
        }
90
        return (int)$result;
91
    }
92

src/storage/repository/ContentRepository.php 3 locations

@@ 47-51 (lines=5) @@
44
        {
45
            $db = $this->getContentDbHandle();
46
            $stmt = $db->query($sql);
47
            if ($stmt === false) {
48
                $errorInfo = $db->errorInfo();
49
                $errorMsg = $errorInfo[2];
50
                throw new \RuntimeException('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
51
            }
52
            return $stmt;
53
        }
54
@@ 260-264 (lines=5) @@
257
		';
258
            $stmt = $db->query($sql);
259
            $result = $stmt->fetchAll(\PDO::FETCH_CLASS, Document::class);
260
            if ($stmt === false || !$stmt->execute()) {
261
                $errorInfo = $db->errorInfo();
262
                $errorMsg = $errorInfo[2];
263
                throw new \RuntimeException('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
264
            }
265
            return $result;
266
        }
267
@@ 306-310 (lines=5) @@
303
            }
304
            $db = $this->getContentDbHandle();
305
            $stmt = $db->prepare($sql);
306
            if ($stmt === false) {
307
                $errorInfo = $db->errorInfo();
308
                $errorMsg = $errorInfo[2];
309
                throw new \RuntimeException('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
310
            }
311
            $stmt->bindValue(':path', $path);
312
            $stmt->execute();
313
        }

src/storage/Cache.php 3 locations

@@ 58-64 (lines=7) @@
55
        ';
56
        $stmt = $dbInstace->prepare($sql);
57
        $stmt->bindParam(':path', $path);
58
        if ($stmt->execute()) {
59
            return $stmt->fetch(\PDO::FETCH_OBJ);
60
        } else {
61
            $error = $stmt->errorInfo();
62
            $errorMsg = $error[2];
63
            throw new \RuntimeException('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
64
        }
65
    }
66
67
    /**
@@ 78-84 (lines=7) @@
75
            VACUUM;
76
        ';
77
        $stmt = $dbInstace->prepare($sql);
78
        if ($stmt->execute()) {
79
            return;
80
        } else {
81
            $error = $stmt->errorInfo();
82
            $errorMsg = $error[2];
83
            throw new \RuntimeException('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
84
        }
85
    }
86
87
    /**
@@ 139-145 (lines=7) @@
136
        $stmt->bindParam(':path', $requestUri);
137
        $stmt->bindParam(':creationStamp', $creationStamp);
138
        $stmt->bindParam(':contents', $contents);
139
        if ($stmt->execute()) {
140
            return;
141
        } else {
142
            $error = $stmt->errorInfo();
143
            $errorMsg = $error[2];
144
            throw new \RuntimeException('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
145
        }
146
    }
147
148
}