PaymentMethod::setCapture()   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\Model;
4
5
use Ipag\Sdk\Model\Schema\Mutator;
6
use Ipag\Sdk\Model\Schema\Schema;
7
use Ipag\Sdk\Model\Schema\SchemaBuilder;
8
use Kubinyete\Assertation\Assert;
9
10
/**
11
 * PaymentMethod Class
12
 *
13
 * Classe responsável por representar o recurso PaymentMethod.
14
 */
15
class PaymentMethod extends Model
16
{
17
18
    /**
19
     * @param array|null $data
20
     * array de dados do recurso `PaymentMethod`
21
     *
22
     *  + [`'acquirer'`] string (opcional).
23
     *  + [`'priority'`] int (opcional) {`Range: 0 à 100`}.
24
     *  + [`'environment'`] enum {`'production'` | `'test'` | `'inactive'`} (opcional).
25
     *  + [`'capture'`] bool (opcional).
26
     *  + [`'retry'`] bool (opcional).
27
     *  + [`'credentials'`] array (opcional).
28
     */
29
    public function __construct(?array $data = [])
30
    {
31
        parent::__construct($data);
32
    }
33
34
    protected function schema(SchemaBuilder $schema): Schema
35
    {
36
        $schema->string('acquirer')->nullable();
37
38
        $schema->int('priority')->nullable();
39
40
        $schema->enum('environment', ['production', 'test', 'inactive'])->nullable();
41
42
        $schema->bool('capture')->nullable();
43
44
        $schema->bool('retry')->nullable();
45
46
        $schema->any('credentials')->nullable();
47
48
        return $schema->build();
49
    }
50
51
    protected function priority(): Mutator
52
    {
53
        return new Mutator(
54
            null,
55
            fn($value, $ctx) =>
56
            is_null($value) ? $value :
57
            (
58
                Assert::value(intval($value))->gte(0)->get()
59
                ?? $ctx->raise('inválido')
60
            )
61
        );
62
    }
63
64
    /**
65
     * Retorna o valor da propriedade `acquirer`.
66
     *
67
     * @return string|null
68
     */
69
    public function getAcquirer(): ?string
70
    {
71
        return $this->get('acquirer');
72
    }
73
74
    /**
75
     * Retorna o valor da propriedade `acquirer`.
76
     *
77
     * @param string|null $acquirer
78
     * @return self
79
     */
80
    public function setAcquirer(?string $acquirer = null): self
81
    {
82
        $this->set('acquirer', $acquirer);
83
        return $this;
84
    }
85
86
    /**
87
     * Retorna o valor da propriedade `priority`.
88
     *
89
     * @return integer|null
90
     */
91
    public function getPriority(): ?int
92
    {
93
        return $this->get('priority');
94
    }
95
96
    /**
97
     * Seta o valor da propriedade `priority`.
98
     *
99
     * @param integer|null $priority
100
     * @return self
101
     */
102
    public function setPriority(?int $priority = null): self
103
    {
104
        $this->set('priority', $priority);
105
        return $this;
106
    }
107
108
    /**
109
     * Retorna o valor da propriedade `environment`.
110
     *
111
     * @return string|null
112
     */
113
    public function getEnvironment(): ?string
114
    {
115
        return $this->get('environment');
116
    }
117
118
    /**
119
     * Seta o valor da propriedade `environment`.
120
     *
121
     * @param string|null $environment
122
     * @return self
123
     */
124
    public function setEnvironment(?string $environment = null): self
125
    {
126
        $this->set('environment', $environment);
127
        return $this;
128
    }
129
130
    /**
131
     * Retorna o valor da propriedade `capture`.
132
     *
133
     * @return boolean|null
134
     */
135
    public function getCapture(): ?bool
136
    {
137
        return $this->get('capture');
138
    }
139
140
    /**
141
     * Seta o valor da propriedade `capture`.
142
     *
143
     * @param boolean|null $capture
144
     * @return self
145
     */
146
    public function setCapture(?bool $capture = null): self
147
    {
148
        $this->set('capture', $capture);
149
        return $this;
150
    }
151
152
    /**
153
     * Retorna o valor da propriedade `retry`.
154
     *
155
     * @return boolean|null
156
     */
157
    public function getRetry(): ?bool
158
    {
159
        return $this->get('retry');
160
    }
161
162
    /**
163
     * Seta o valor da propriedade `retry`.
164
     *
165
     * @param boolean|null $retry
166
     * @return self
167
     */
168
    public function setRetry(?bool $retry = null): self
169
    {
170
        $this->set('retry', $retry);
171
        return $this;
172
    }
173
174
    /**
175
     * Retorna o valor da propriedade `credentials`.
176
     *
177
     * @return array|null
178
     */
179
    public function getCredentials(): ?array
180
    {
181
        return $this->get('credentials');
182
    }
183
184
    /**
185
     * Seta o valor da propriedade `credentials`.
186
     *
187
     * @param array|null $credentials
188
     * @return self
189
     */
190
    public function setCredentials(?array $credentials = null): self
191
    {
192
        $this->set('credentials', $credentials);
193
        return $this;
194
    }
195
196
}