Code Duplication    Length = 10-14 lines in 3 locations

src/DelayHandler.php 1 location

@@ 57-66 (lines=10) @@
54
     * @param int $delay - in seconds
55
     * @return bool
56
     */
57
    public function clean($delay = 60)
58
    {
59
        $query = $this->pdo->prepare(<<<SQL
60
DELETE FROM robotstxt__delay0
61
WHERE delayUntil < ((UNIX_TIMESTAMP() - :delay) * 1000000);
62
SQL
63
        );
64
        $query->bindParam(':delay', $delay, PDO::PARAM_INT);
65
        return $query->execute();
66
    }
67
68
    /**
69
     * Top X wait time

src/Cache.php 2 locations

@@ 157-170 (lines=14) @@
154
     * @param int|null $workerID
155
     * @return bool
156
     */
157
    private function markAsActive($base, $workerID = 0)
158
    {
159
        if ($workerID == 0) {
160
            $query = $this->pdo->prepare(<<<SQL
161
UPDATE robotstxt__cache1
162
SET worker = NULL
163
WHERE base = :base AND worker = 0;
164
SQL
165
            );
166
            $query->bindParam(':base', $base, PDO::PARAM_STR);
167
            return $query->execute();
168
        }
169
        return true;
170
    }
171
172
    /**
173
     * Update an robots.txt in the database
@@ 333-343 (lines=11) @@
330
     * @param int $delay - in seconds
331
     * @return bool
332
     */
333
    public function clean($delay = 600)
334
    {
335
        $delay = self::CACHE_TIME + $delay;
336
        $query = $this->pdo->prepare(<<<SQL
337
DELETE FROM robotstxt__cache1
338
WHERE worker = 0 AND nextUpdate < (UNIX_TIMESTAMP() - :delay);
339
SQL
340
        );
341
        $query->bindParam(':delay', $delay, PDO::PARAM_INT);
342
        return $query->execute();
343
    }
344
}
345