|
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
|
|
|
* Buttons Class |
|
12
|
|
|
* |
|
13
|
|
|
* Classe responsável por representar o recurso Buttons. |
|
14
|
|
|
*/ |
|
15
|
|
|
class Buttons extends Model |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @param array $data |
|
19
|
|
|
* array de dados do Buttons. |
|
20
|
|
|
* |
|
21
|
|
|
* + [`'enable'`] bool (opcional). |
|
22
|
|
|
* + [`'one'`] float (opcional). |
|
23
|
|
|
* + [`'two'`] float (opcional). |
|
24
|
|
|
* + [`'three'`] float (opcional). |
|
25
|
|
|
* + [`'description'`] string (opcional). |
|
26
|
|
|
* + [`'header'`] string (opcional). |
|
27
|
|
|
* + [`'subHeader'`] string (opcional). |
|
28
|
|
|
* + [`'expireAt'`] string (opcional) {Formato: `Y-m-d H:i:s`}. |
|
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('enable')->nullable(); |
|
38
|
|
|
$schema->float('one')->nullable(); |
|
39
|
|
|
$schema->float('two')->nullable(); |
|
40
|
|
|
$schema->float('three')->nullable(); |
|
41
|
|
|
$schema->string('description')->nullable(); |
|
42
|
|
|
$schema->string('header')->nullable(); |
|
43
|
|
|
$schema->string('subHeader')->nullable(); |
|
44
|
|
|
$schema->string('expireAt')->nullable(); |
|
45
|
|
|
|
|
46
|
|
|
return $schema->build(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected function one(): Mutator |
|
50
|
|
|
{ |
|
51
|
|
|
return new Mutator( |
|
52
|
|
|
null, |
|
53
|
|
|
fn($value, $ctx) => |
|
54
|
|
|
is_null($value) ? $value : |
|
55
|
|
|
( |
|
56
|
|
|
Assert::value(floatval($value))->gte(0)->get() |
|
57
|
|
|
?? $ctx->raise('inválido') |
|
58
|
|
|
) |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function two(): Mutator |
|
63
|
|
|
{ |
|
64
|
|
|
return new Mutator( |
|
65
|
|
|
null, |
|
66
|
|
|
fn($value, $ctx) => |
|
67
|
|
|
is_null($value) ? $value : |
|
68
|
|
|
( |
|
69
|
|
|
Assert::value(floatval($value))->gte(0)->get() |
|
70
|
|
|
?? $ctx->raise('inválido') |
|
71
|
|
|
) |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
protected function three(): Mutator |
|
76
|
|
|
{ |
|
77
|
|
|
return new Mutator( |
|
78
|
|
|
null, |
|
79
|
|
|
fn($value, $ctx) => |
|
80
|
|
|
is_null($value) ? $value : |
|
81
|
|
|
( |
|
82
|
|
|
Assert::value(floatval($value))->gte(0)->get() |
|
83
|
|
|
?? $ctx->raise('inválido') |
|
84
|
|
|
) |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function getEnable(): ?bool |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->get('enable'); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function setEnable(?bool $enable): self |
|
94
|
|
|
{ |
|
95
|
|
|
$this->set('enable', $enable); |
|
96
|
|
|
return $this; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function getOne(): ?float |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->get('one'); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function setOne(?float $one): self |
|
105
|
|
|
{ |
|
106
|
|
|
$this->set('one', $one); |
|
107
|
|
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function getTwo(): ?float |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->get('two'); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function setTwo(?float $two): self |
|
116
|
|
|
{ |
|
117
|
|
|
$this->set('two', $two); |
|
118
|
|
|
return $this; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function getThree(): ?float |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->get('three'); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function setThree(?float $three): self |
|
127
|
|
|
{ |
|
128
|
|
|
$this->set('three', $three); |
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function getDescription(): ?string |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->get('description'); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function setDescription(?string $description): self |
|
138
|
|
|
{ |
|
139
|
|
|
$this->set('description', $description); |
|
140
|
|
|
return $this; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function getHeader(): ?string |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->get('header'); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
public function setHeader(?string $header): self |
|
149
|
|
|
{ |
|
150
|
|
|
$this->set('header', $header); |
|
151
|
|
|
return $this; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function getSubHeader(): ?string |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->get('subHeader'); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function setSubHeader(?string $subHeader): self |
|
160
|
|
|
{ |
|
161
|
|
|
$this->set('subHeader', $subHeader); |
|
162
|
|
|
return $this; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
public function getExpireAt(): ?string |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->get('expireAt'); |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
public function setExpireAt(?string $expireAt): self |
|
171
|
|
|
{ |
|
172
|
|
|
$this->set('expireAt', $expireAt); |
|
173
|
|
|
return $this; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
} |