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

@@ 158-171 (lines=14) @@
155
     * @param int|null $workerID
156
     * @return bool
157
     */
158
    private function markAsActive($base, $workerID = 0)
159
    {
160
        if ($workerID == 0) {
161
            $query = $this->pdo->prepare(<<<SQL
162
UPDATE robotstxt__cache1
163
SET worker = NULL
164
WHERE base = :base AND worker = 0;
165
SQL
166
            );
167
            $query->bindParam(':base', $base, PDO::PARAM_STR);
168
            return $query->execute();
169
        }
170
        return true;
171
    }
172
173
    /**
174
     * Update an robots.txt in the database
@@ 346-356 (lines=11) @@
343
     * @param int $delay - in seconds
344
     * @return bool
345
     */
346
    public function clean($delay = 600)
347
    {
348
        $delay = self::CACHE_TIME + $delay;
349
        $query = $this->pdo->prepare(<<<SQL
350
DELETE FROM robotstxt__cache1
351
WHERE worker = 0 AND nextUpdate < (UNIX_TIMESTAMP() - :delay);
352
SQL
353
        );
354
        $query->bindParam(':delay', $delay, PDO::PARAM_INT);
355
        return $query->execute();
356
    }
357
}
358