Completed
Push — master ( d2b3f3...05ef8e )
by João Felipe Magro
02:25
created

Authentication::serialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace Ipag\Classes;
4
5
use Ipag\Classes\Contracts\Emptiable;
6
use Ipag\Classes\Contracts\Serializable;
7
use Ipag\Classes\Traits\EmptiableTrait;
8
9
final class Authentication implements Emptiable, Serializable
10
{
11
    use EmptiableTrait;
12
13
    /**
14
     * @var string
15
     */
16
    private $identification;
17
18
    /**
19
     * @var string
20
     */
21
    private $identification2;
22
23
    /**
24
     * @var string
25
     */
26
    private $apiKey;
27
28
    public function __construct($identification, $apiKey = null)
29
    {
30
        $this->identification = $identification;
31
        $this->apiKey = $apiKey;
32
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function getIdentification()
38
    {
39
        return $this->identification;
40
    }
41
42
    /**
43
     * @param string $identification
44
     */
45
    public function setIdentification($identification)
46
    {
47
        $this->identification = substr((string) $identification, 0, 50);
48
49
        return $this;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getIdentification2()
56
    {
57
        return $this->identification2;
58
    }
59
60
    /**
61
     * @param string $identification2 the identification2
62
     */
63
    public function setIdentification2($identification2)
64
    {
65
        $this->identification2 = substr((string) $identification2, 0, 50);
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getApiKey()
74
    {
75
        return $this->apiKey;
76
    }
77
78
    /**
79
     * @param string $apiKey
80
     */
81
    public function setApiKey($apiKey)
82
    {
83
        $this->apiKey = $apiKey;
84
85
        return $this;
86
    }
87
88
    public function serialize()
89
    {
90
        $_user = [
91
            'identificacao' => urlencode($this->getIdentification()),
92
        ];
93
94
        $parceiro = $this->getIdentification2();
95
        if (!empty($parceiro)) {
96
            $_user['identificacao2'] = urlencode($parceiro);
97
        }
98
99
        return $_user;
100
    }
101
}
102