CoreFiles by mySites.guru
BaseChallengeOptions.php48 lines, 1,108 bytes, from Joomla_6.1.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 6.1.0-alpha1
md5
18fd950939831989f3706b28c5ddad3f
sha1
145bbfcc2daf4b0206413c23c04d2ff5c55c04bb
sha256
b132b0b3312785c582a5d0624499ea615decf1f5f7a5b39854532c273403541b
<?php

declare(strict_types=1);

namespace AltchaOrg\Altcha;

use AltchaOrg\Altcha\Hasher\Algorithm;

/**
 * @phpstan-type ChallengeParams array<string, null|scalar>
 */
class BaseChallengeOptions
{
    public const DEFAULT_MAX_NUMBER = 1000000;

    public readonly string $salt;

    /**
     * Options for creation of a new challenge.
     *
     * @see ChallengeOptions for options with sane defaults.
     *
     * @param ChallengeParams $params
     */
    public function __construct(
        public readonly Algorithm $algorithm,
        public readonly int $maxNumber,
        public readonly ?\DateTimeInterface $expires,
        string $salt,
        public readonly int $number,
        public readonly array $params,
    ) {
        if ($expires) {
            $params['expires'] = $expires->getTimestamp();
        }

        if (!empty($params)) {
            $salt .= '?' . http_build_query($params);
        }

        // Add a delimiter to prevent parameter splicing
        if (!str_ends_with($salt, ';')) {
            $salt = $salt . ';';
        }

        $this->salt = $salt;
    }
}

No other release has this exact content. See every version of this file.