<commit_before><?php

declare(strict_types=1);

/*
 * eduVPN - End-user friendly VPN.
 *
 * Copyright: 2016-2021, The Commons Conservancy eduVPN Programme
 * SPDX-License-Identifier: AGPL-3.0+
 */

namespace LC\Portal;

use DateInterval;
use DateTimeImmutable;

class Expiry
{
    /**
     * Calculate when a session will expire.
     *
     * The goal is to expire at 04:00 in the current timezone. in case the
     * expiry is set 1 week or longer. The current timezone is considerd as
     * per date.timezone PHP ini value.
     */
    public static function calculate(DateInterval $sessionExpiry, ?DateTimeImmutable $dateTime = null): DateInterval
    {
        if (null === $dateTime) {
            $dateTime = new DateTimeImmutable();
        }

        $expiresAt = $dateTime->add($sessionExpiry);

        // if we expire less than 7 days from now, keep as is
        if ($expiresAt < $dateTime->add(new DateInterval('P7D'))) {
            return $sessionExpiry;
        }<commit_msg>fix comment in Expiry class<commit_after><?php

declare(strict_types=1);

/*
 * eduVPN - End-user friendly VPN.
 *
 * Copyright: 2016-2021, The Commons Conservancy eduVPN Programme
 * SPDX-License-Identifier: AGPL-3.0+
 */

namespace LC\Portal;

use DateInterval;
use DateTimeImmutable;

class Expiry
{
    /**
     * Calculate when a session will expire.
     *
     * The goal is to expire "sessions" at 02:00 in the current timezone, iff
     * the expiry is set 1 week or longer. The current timezone is considered
     * as per date.timezone PHP ini value.
     */
    public static function calculate(DateInterval $sessionExpiry, ?DateTimeImmutable $dateTime = null): DateInterval
    {
        if (null === $dateTime) {
            $dateTime = new DateTimeImmutable();
        }

        $expiresAt = $dateTime->add($sessionExpiry);

        // if we expire less than 7 days from now, keep as is
        if ($expiresAt < $dateTime->add(new DateInterval('P7D'))) {
            return $sessionExpiry;
        }
{'fraction_non_alphanumeric': 0.10159362549800798, 'fraction_numerical': 0.017928286852589643, 'mean_word_length': 2.706642066420664, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7170274', 'n_tokens_mistral': 652, 'n_tokens_neox': 605, 'n_words': 196}