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

UserSetHash::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
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
}