Code Duplication    Length = 16-16 lines in 2 locations

src/EventSourcing/EventStore/Vendor/DoctrineDbalEventStore.php 1 location

@@ 242-257 (lines=16) @@
239
     * @return int
240
     * @throws EventStreamDoesNotExistException
241
     */
242
    public function getStreamVersionAt($streamId, \DateTimeImmutable $datetime)
243
    {
244
        if (!$this->streamExists($streamId)) {
245
            throw EventStreamDoesNotExistException::fromStreamId($streamId);
246
        }
247
        $stmt = $this->connection->prepare(
248
            'SELECT COUNT(*)
249
             FROM events
250
             WHERE stream_id = :streamId
251
             AND occurred_on <= :occurred_on'
252
        );
253
        $stmt->bindValue(':streamId', $streamId);
254
        $stmt->bindValue(':occurred_on', $datetime->format('Y-m-d H:i:s'));
255
        $stmt->execute();
256
        return intval($stmt->fetchColumn());
257
    }
258
259
    /**
260
     * @param string $streamId

src/EventSourcing/EventStore/Vendor/MySqlJsonEventStore.php 1 location

@@ 309-324 (lines=16) @@
306
     * @return int
307
     * @throws EventStreamDoesNotExistException
308
     */
309
    public function getStreamVersionAt($streamId, \DateTimeImmutable $datetime)
310
    {
311
        if (!$this->streamExists($streamId)) {
312
            throw EventStreamDoesNotExistException::fromStreamId($streamId);
313
        }
314
        $stmt = $this->connection->prepare(
315
            'SELECT COUNT(*)
316
             FROM events
317
             WHERE stream_id = :streamId
318
             AND occurred_on <= :occurred_on'
319
        );
320
        $stmt->bindValue(':streamId', $streamId);
321
        $stmt->bindValue(':occurred_on', $datetime->format('Y-m-d H:i:s'));
322
        $stmt->execute();
323
        return intval($stmt->fetchColumn());
324
    }
325
}
326