RedShieldProvider::setCredentials()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Ipag\Sdk\Support\Provider\Antifraudes;
4
5
use Ipag\Sdk\Model\Model;
6
use Ipag\Sdk\Model\Schema\Schema;
7
use Ipag\Sdk\Model\Schema\SchemaBuilder;
8
use Ipag\Sdk\Support\Credentials\Antifraudes\RedShieldCredentials;
9
10
/**
11
 * RedShieldProvider Class
12
 *
13
 * Classe responsável pelo provider da identidade `Red Shield`.
14
 */
15
final class RedShieldProvider extends Model
16
{
17
    /**
18
     *  @param array $data
19
     *  array de dados do Red Shield Credentials.
20
     *
21
     *  + [`'token'`] string (opcional).
22
     *  + [`'entityId'`] string (opcional).
23
     *  + [`'channelId'`] string (opcional).
24
     *  + [`'serviceId'`] string (opcional).
25
     */
26
    public function __construct(?array $data = null)
27
    {
28
        parent::__construct([
29
            'name' => 'redshield',
30
            'credentials' => $data
31
        ]);
32
    }
33
34
    public function schema(SchemaBuilder $schema): Schema
35
    {
36
        $schema->string('name')->default('redshield')->nullable();
37
        $schema->has('credentials', RedShieldCredentials::class)->nullable();
38
39
        return $schema->build();
40
    }
41
42
    /**
43
     * Retorna o valor da propriedade `name`.
44
     *
45
     * @return string|null
46
     */
47
    public function getName(): ?string
48
    {
49
        return $this->get('name');
50
    }
51
52
    /**
53
     * Retorna o valor da propriedade `credentials`.
54
     *
55
     * @return RedShieldCredentials|null
56
     */
57
    public function getCredentials(): ?RedShieldCredentials
58
    {
59
        return $this->get('credentials');
60
    }
61
62
    /**
63
     * Seta o valor da propriedade `credentials`.
64
     *
65
     * @param RedShieldCredentials|null $credentials
66
     * @return self
67
     */
68
    public function setCredentials(?RedShieldCredentials $credentials = null): self
69
    {
70
        $this->set('credentials', $credentials);
71
        return $this;
72
    }
73
74
}