Test Setup Failed
Push — master ( 6863da...811519 )
by guillaume
27:05 queued 21:33
created

Invitation::hash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
4
namespace App\Src\UseCases\Domain;
5
6
7
use App\Src\Utils\Hash\HashGen;
8
9
class Invitation
10
{
11
    private $organizationId;
12
    private $email;
13
    private $firstname;
14
    private $lastname;
15
    private $token;
16
    private $hash;
17
18
    public function __construct(string $organizationId, string $email, ?string $firstname = null, ?string $lastname = null)
19
    {
20
        $this->organizationId = $organizationId;
21
        $this->email = $email;
22
        $this->firstname = $firstname;
23
        $this->lastname = $lastname;
24
        $this->token = base64_encode($organizationId.'|*|'.$email.'|*|'.$firstname.'|*|'.$lastname);
25
        $this->hash = app(HashGen::class)->hash($this->token);
26
    }
27
28
    public function hash():string
29
    {
30
        return $this->hash;
31
    }
32
33
    public function data():array
34
    {
35
        return [
36
            $this->organizationId,
37
            $this->email,
38
            $this->firstname,
39
            $this->lastname,
40
        ];
41
    }
42
}
43