UserSetHash   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A set() 0 8 1
1
<?php
2
3
namespace App\Security;
4
5
6
use App\Entity\User;
7
use DateTime;
8
use Exception;
9
10
class UserSetHash
11
{
12
13
    /**
14
     * @param User $user
15
     * @return string
16
     * @throws Exception
17
     * Sets a new hash to the verifiedDateTimeField of the passed user
18
     */
19
    public function set(User $user): string
20
    {
21
        $hash = bin2hex(random_bytes(16));
22
        $user->setVerifiedHash($hash);
23
24
        $user->setVerifiedDateTime(new DateTime());
25
26
        return $hash;
27
    }
28
}