MailPoet\EmailEditor\Validator\Schema

Integer_Schema{}WC 1.0

Represents a schema for an integer. See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#numbers

No Hooks.

Usage

$Integer_Schema = new Integer_Schema();
// use class methods

Methods

  1. public exclusiveMaximum( int $value )
  2. public exclusiveMinimum( int $value )
  3. public maximum( int $value )
  4. public minimum( int $value )
  5. public multipleOf( int $value )

Integer_Schema{} code WC 9.8.1

class Integer_Schema extends Schema {
	/**
	 * Schema definition.
	 *
	 * @var array
	 */
	protected $schema = array(
		'type' => 'integer',
	);

	/**
	 * Sets the minimum value of the integer.
	 *
	 * @param int $value Minimum value of the integer.
	 */
	public function minimum( int $value ): self {
		return $this->update_schema_property( 'minimum', $value )
		->unset_schema_property( 'exclusiveMinimum' );
	}

	/**
	 * Sets the exclusiveMinimum property to true.
	 *
	 * @param int $value Minimum value of the integer.
	 */
	public function exclusiveMinimum( int $value ): self {
		return $this->update_schema_property( 'minimum', $value )
		->update_schema_property( 'exclusiveMinimum', true );
	}

	/**
	 * Sets the maximum value of the integer.
	 *
	 * @param int $value Maximum value of the integer.
	 */
	public function maximum( int $value ): self {
		return $this->update_schema_property( 'maximum', $value )
		->unset_schema_property( 'exclusiveMaximum' );
	}

	/**
	 * Sets the exclusiveMaximum property to true.
	 *
	 * @param int $value Maximum value of the integer.
	 */
	public function exclusiveMaximum( int $value ): self {
		return $this->update_schema_property( 'maximum', $value )
		->update_schema_property( 'exclusiveMaximum', true );
	}

	/**
	 * Sets the multipleOf property.
	 *
	 * @param int $value Multiple of the integer.
	 */
	public function multipleOf( int $value ): self {
		return $this->update_schema_property( 'multipleOf', $value );
	}
}