Code Duplication    Length = 21-21 lines in 2 locations

src/Shutdown/PredisShutdown.php 1 location

@@ 37-57 (lines=21) @@
34
     * - and timestamp is not in future,
35
     * - and hermes was started ($startTime) before timestamp
36
     */
37
    public function shouldShutdown(DateTime $startTime): bool
38
    {
39
        // load UNIX timestamp from redis
40
        $shutdownTime = $this->redis->get($this->key);
41
        if ($shutdownTime === null) {
42
            return false;
43
        }
44
        $shutdownTime = (int) $shutdownTime;
45
46
        // do not shutdown if shutdown time is in future
47
        if ($shutdownTime > time()) {
48
            return false;
49
        }
50
51
        // do not shutdown if hermes started after shutdown time
52
        if ($shutdownTime < $startTime->getTimestamp()) {
53
            return false;
54
        }
55
56
        return true;
57
    }
58
59
    /**
60
     * {@inheritdoc}

src/Shutdown/RedisShutdown.php 1 location

@@ 36-56 (lines=21) @@
33
     * - and timestamp is not in future,
34
     * - and hermes was started ($startTime) before timestamp
35
     */
36
    public function shouldShutdown(DateTime $startTime): bool
37
    {
38
        // load UNIX timestamp from redis
39
        $shutdownTime = $this->redis->get($this->key);
40
        if ($shutdownTime == null) {
41
            return false;
42
        }
43
        $shutdownTime = (int) $shutdownTime;
44
45
        // do not shutdown if shutdown time is in future
46
        if ($shutdownTime > time()) {
47
            return false;
48
        }
49
50
        // do not shutdown if hermes started after shutdown time
51
        if ($shutdownTime < $startTime->getTimestamp()) {
52
            return false;
53
        }
54
55
        return true;
56
    }
57
58
    /**
59
     * {@inheritdoc}