Code Duplication    Length = 16-16 lines in 2 locations

src/Surfnet/StepupRa/RaBundle/Security/Authentication/Session/SessionLifetimeGuard.php 2 locations

@@ 56-71 (lines=16) @@
53
     * @param AuthenticatedSessionStateHandler $sessionStateHandler
54
     * @return bool
55
     */
56
    public function sessionLifetimeWithinAbsoluteLimit(AuthenticatedSessionStateHandler $sessionStateHandler)
57
    {
58
        if (!$sessionStateHandler->isAuthenticationMomentLogged()) {
59
            return true;
60
        }
61
62
        $authenticationMoment = $sessionStateHandler->getAuthenticationMoment();
63
        $sessionTimeoutMoment = $this->absoluteTimeoutLimit->getEndWhenStartingAt($authenticationMoment);
64
        $now = DateTime::now();
65
66
        if ($now->comesBeforeOrIsEqual($sessionTimeoutMoment)) {
67
            return true;
68
        }
69
70
        return false;
71
    }
72
73
    /**
74
     * @param AuthenticatedSessionStateHandler $sessionStateHandler
@@ 77-92 (lines=16) @@
74
     * @param AuthenticatedSessionStateHandler $sessionStateHandler
75
     * @return bool
76
     */
77
    public function sessionLifetimeWithinRelativeLimit(AuthenticatedSessionStateHandler $sessionStateHandler)
78
    {
79
        if (!$sessionStateHandler->hasSeenInteraction()) {
80
            return true;
81
        }
82
83
        $lastInteractionMoment = $sessionStateHandler->getLastInteractionMoment();
84
        $sessionTimeoutMoment = $this->relativeTimeoutLimit->getEndWhenStartingAt($lastInteractionMoment);
85
        $now = DateTime::now();
86
87
        if ($now->comesBeforeOrIsEqual($sessionTimeoutMoment)) {
88
            return true;
89
        }
90
91
        return false;
92
    }
93
}
94