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

Invitation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 31
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A data() 0 7 1
A hash() 0 3 1
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