AnyOfSchema.php
4 years ago
ArraySchema.php
4 years ago
BooleanSchema.php
4 years ago
IntegerSchema.php
4 years ago
NullSchema.php
4 years ago
NumberSchema.php
4 years ago
ObjectSchema.php
4 years ago
OneOfSchema.php
4 years ago
StringSchema.php
4 years ago
index.php
3 years ago
IntegerSchema.php
40 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Validator\Schema; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Validator\Schema; |
| 9 | |
| 10 | // See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#numbers |
| 11 | class IntegerSchema extends Schema { |
| 12 | protected $schema = [ |
| 13 | 'type' => 'integer', |
| 14 | ]; |
| 15 | |
| 16 | public function minimum(int $value): self { |
| 17 | return $this->updateSchemaProperty('minimum', $value) |
| 18 | ->unsetSchemaProperty('exclusiveMinimum'); |
| 19 | } |
| 20 | |
| 21 | public function exclusiveMinimum(int $value): self { |
| 22 | return $this->updateSchemaProperty('minimum', $value) |
| 23 | ->updateSchemaProperty('exclusiveMinimum', true); |
| 24 | } |
| 25 | |
| 26 | public function maximum(int $value): self { |
| 27 | return $this->updateSchemaProperty('maximum', $value) |
| 28 | ->unsetSchemaProperty('exclusiveMaximum'); |
| 29 | } |
| 30 | |
| 31 | public function exclusiveMaximum(int $value): self { |
| 32 | return $this->updateSchemaProperty('maximum', $value) |
| 33 | ->updateSchemaProperty('exclusiveMaximum', true); |
| 34 | } |
| 35 | |
| 36 | public function multipleOf(int $value): self { |
| 37 | return $this->updateSchemaProperty('multipleOf', $value); |
| 38 | } |
| 39 | } |
| 40 |