MCP PHP SDK

NumberSchemaDefinition extends AbstractSchemaDefinition

FinalYes

Schema definition for number/integer fields in elicitation requests.

Supports minimum and maximum value constraints.

Tags
author

Johannes Wachter johannes@sulu.io

Table of Contents

Properties

$default  : int|float|null
$description  : string|null
$integerOnly  : bool
$maximum  : int|float|null
$minimum  : int|float|null
$title  : string|null

Methods

__construct()  : mixed
fromArray()  : self
jsonSerialize()  : array{type: string, title?: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}
buildBaseJson()  : array<string, mixed>
Build the base JSON structure with type, optional title and description.
validateTitle()  : void
Reject a title that is present but not a string.

Properties

Methods

__construct()

public __construct([string|null $title = null ][, bool $integerOnly = false ][, string|null $description = null ][, int|float|null $default = null ][, int|float|null $minimum = null ][, int|float|null $maximum = null ]) : mixed
Parameters
$title : string|null = null

Optional human-readable title for the field

$integerOnly : bool = false

Whether to restrict to integer values only

$description : string|null = null

Optional description/help text

$default : int|float|null = null

Optional default value

$minimum : int|float|null = null

Optional minimum value (inclusive)

$maximum : int|float|null = null

Optional maximum value (inclusive)

fromArray()

public static fromArray(array{type: string, title?: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float} $data) : self
Parameters
$data : array{type: string, title?: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}
Return values
self

jsonSerialize()

public jsonSerialize() : array{type: string, title?: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}
Return values
array{type: string, title?: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}

buildBaseJson()

Build the base JSON structure with type, optional title and description.

protected buildBaseJson(string $type) : array<string, mixed>
Parameters
$type : string
Return values
array<string, mixed>

validateTitle()

Reject a title that is present but not a string.

protected static validateTitle(array<string, mixed> $data, string $schemaType) : void
Parameters
$data : array<string, mixed>
$schemaType : string
Tags
throws
InvalidArgumentException
On this page

Search results