1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus framework.
7: *
8: * (c) John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Password\Hash;
15:
16: use Nexus\Password\Algorithm;
17: use Nexus\Password\HashException;
18:
19: final readonly class Argon2idHash extends AbstractArgon2Hash
20: {
21: /**
22: * @param array{
23: * memory_cost?: int,
24: * time_cost?: int,
25: * threads?: int,
26: * ...<string, mixed>
27: * } $options
28: *
29: * @throws HashException
30: */
31: public function __construct(Algorithm $algorithm, array $options = [])
32: {
33: if (Algorithm::Argon2id !== $algorithm) {
34: throw new HashException(\sprintf(
35: 'Algorithm expected to be Algorithm::Argon2id, Algorithm::%s given.',
36: $algorithm->name,
37: ));
38: }
39:
40: parent::__construct($algorithm, $options);
41: }
42:
43: #[\Override]
44: public function valid(): bool
45: {
46: return \defined('PASSWORD_ARGON2ID');
47: }
48: }
49: