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: * } $options
27: *
28: * @throws HashException
29: */
30: public function __construct(Algorithm $algorithm, array $options = [])
31: {
32: if (Algorithm::Argon2id !== $algorithm) {
33: throw new HashException(\sprintf(
34: 'Algorithm expected to be Algorithm::Argon2id, Algorithm::%s given.',
35: $algorithm->name,
36: ));
37: }
38:
39: parent::__construct($algorithm, $options);
40: }
41:
42: public function valid(): bool
43: {
44: return \defined('PASSWORD_ARGON2ID');
45: }
46: }
47: