Passed
Push — master ( 786b21...4a8f5f )
by Stone
06:47 queued 42s
created

UserSetHash   A

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
8
class UserSetHash
9
{
10
11
    /**
12
     * @param User $user
13
     * @return string
14
     * @throws \Exception
15
     * Sets a new hash to the verifiedDateTimeField of the passed user
16
     */
17
    public function set(User $user): string
18
    {
19
        $hash = bin2hex(random_bytes(16));
20
        $user->setVerifiedHash($hash);
21
22
        $user->setVerifiedDateTime(new \DateTime());
23
24
        return $hash;
25
    }
26
}