AntifraudSettings   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 175
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
c 1
b 0
f 0
dl 0
loc 175
rs 10
wmc 16

15 Methods

Rating   Name   Duplication   Size   Complexity  
A schema() 0 10 1
A setEnabled() 0 4 1
A getEnabled() 0 3 1
A setReviewScoreThreshold() 0 4 1
A setCaptureOnApproval() 0 4 1
A review_score_threshold() 0 9 2
A setCancelOnRefused() 0 4 1
A getCaptureOnApproval() 0 3 1
A getCancelOnRefused() 0 3 1
A getReviewScoreThreshold() 0 3 1
A setEnvironment() 0 4 1
A getConsultMode() 0 3 1
A setConsultMode() 0 4 1
A getEnvironment() 0 3 1
A __construct() 0 3 1
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
 * AntifraudSettings Class
12
 *
13
 * Classe responsável por representar o recurso Antifraud Settings.
14
 */
15
class AntifraudSettings extends Model
16
{
17
18
    /**
19
     *  @param array $data
20
     *  array de dados do recurso `AntifraudSettings`
21
     *
22
     *  + [`'enabled'`] bool (opcional).
23
     *  + [`'environment'`] enum {`'production'` | `'test'`} (opcional).
24
     *  + [`'consult_mode'`] enum {`'auto'` | `'manual'`} (opcional).
25
     *  + [`'capture_on_approval'`] bool (opcional).
26
     *  + [`'cancel_on_refused'`] bool (opcional).
27
     *  + [`'review_score_threshold'`] float (opcional).
28
     */
29
30
    public function __construct(?array $data = [])
31
    {
32
        parent::__construct($data);
33
    }
34
35
    protected function schema(SchemaBuilder $schema): Schema
36
    {
37
        $schema->bool('enabled')->nullable();
38
        $schema->enum('environment', ['production', 'test'])->nullable();
39
        $schema->enum('consult_mode', ['auto', 'manual'])->nullable();
40
        $schema->bool('capture_on_approval')->nullable();
41
        $schema->bool('cancel_on_refused')->nullable();
42
        $schema->float('review_score_threshold')->nullable();
43
44
        return $schema->build();
45
    }
46
47
    protected function review_score_threshold(): Mutator
48
    {
49
        return new Mutator(
50
            null,
51
            fn($value, $ctx) =>
52
            is_null($value) ? $value :
53
            (
54
                Assert::value(floatval($value))->gte(0)->lte(1)->get()
55
                ?? $ctx->raise('inválido')
56
            )
57
        );
58
    }
59
60
    /**
61
     * Retorna o valor da propriedade `enabled`.
62
     *
63
     * @return boolean|null
64
     */
65
    public function getEnabled(): ?bool
66
    {
67
        return $this->get('enabled');
68
    }
69
70
    /**
71
     * Seta o valor da propriedade `enabled`.
72
     *
73
     * @param boolean|null $enabled
74
     * @return self
75
     */
76
    public function setEnabled(?bool $enabled = null): self
77
    {
78
        $this->set('enabled', $enabled);
79
        return $this;
80
    }
81
82
    /**
83
     * Retorna o valor da propriedade `environment`.
84
     *
85
     * @return string|null
86
     */
87
    public function getEnvironment(): ?string
88
    {
89
        return $this->get('environment');
90
    }
91
92
    /**
93
     * Seta o valor da propriedade `environment`.
94
     *
95
     * @param string|null $environment
96
     * @return self
97
     */
98
    public function setEnvironment(?string $environment = null): self
99
    {
100
        $this->set('environment', $environment);
101
        return $this;
102
    }
103
104
    /**
105
     * Retorna o valor da propriedade `consult_mode`.
106
     *
107
     * @return string|null
108
     */
109
    public function getConsultMode(): ?string
110
    {
111
        return $this->get('consult_mode');
112
    }
113
114
    /**
115
     * Seta o valor da propriedade `consult_mode`.
116
     *
117
     * @param string|null $consultMode
118
     * @return self
119
     */
120
    public function setConsultMode(?string $consultMode = null): self
121
    {
122
        $this->set('consult_mode', $consultMode);
123
        return $this;
124
    }
125
126
    /**
127
     * Retorna o valor da propriedade `capture_on_approval`.
128
     *
129
     * @return boolean|null
130
     */
131
    public function getCaptureOnApproval(): ?bool
132
    {
133
        return $this->get('capture_on_approval');
134
    }
135
136
    /**
137
     * Seta o valor da propriedade `capture_on_approval`.
138
     *
139
     * @param boolean|null $captureOnApproval
140
     * @return self
141
     */
142
    public function setCaptureOnApproval(?bool $captureOnApproval = null): self
143
    {
144
        $this->set('capture_on_approval', $captureOnApproval);
145
        return $this;
146
    }
147
148
    /**
149
     * Retorna o valor da propriedade `cancel_on_refused`.
150
     *
151
     * @return boolean|null
152
     */
153
    public function getCancelOnRefused(): ?bool
154
    {
155
        return $this->get('cancel_on_refused');
156
    }
157
158
    /**
159
     * Seta o valor da propriedade `cancel_on_refused`.
160
     *
161
     * @param boolean|null $cancelOnRefused
162
     * @return self
163
     */
164
    public function setCancelOnRefused(?bool $cancelOnRefused = null): self
165
    {
166
        $this->set('cancel_on_refused', $cancelOnRefused);
167
        return $this;
168
    }
169
170
    /**
171
     * Retorna o valor da propriedade `review_score_threshold`.
172
     *
173
     * @return float|null
174
     */
175
    public function getReviewScoreThreshold(): ?float
176
    {
177
        return $this->get('review_score_threshold');
178
    }
179
180
    /**
181
     * Seta o valor da propriedade `review_score_threshold`.
182
     *
183
     * @param float|null $reviewScoreThreshold
184
     * @return self
185
     */
186
    public function setReviewScoreThreshold(?float $reviewScoreThreshold = null): self
187
    {
188
        $this->set('review_score_threshold', $reviewScoreThreshold);
189
        return $this;
190
    }
191
192
}