MCP PHP SDK

EnumSchemaDefinition extends AbstractSchemaDefinition

FinalYes

Schema definition for string enum fields in elicitation requests.

Provides a list of allowed values with optional human-readable labels.

Tags
author

Johannes Wachter johannes@sulu.io

Table of Contents

Properties

$default  : string|null
$description  : string|null
$enum  : array<string|int, mixed>
$enumNames  : array<string|int, mixed>|null
$title  : string

Methods

__construct()  : mixed
fromArray()  : self
jsonSerialize()  : array{type: string, title: string, enum: string[], description?: string, default?: string, enumNames?: string[]}
buildBaseJson()  : array<string, mixed>
Build the base JSON structure with type, title, and optional description.
validateTitle()  : void
Validate that title exists and is a string in the data array.

Properties

Methods

__construct()

public __construct(string $title, array<string|int, string> $enum[, string|null $description = null ][, string|null $default = null ][, array<string|int, string>|null $enumNames = null ]) : mixed
Parameters
$title : string

Human-readable title for the field

$enum : array<string|int, string>

Array of allowed string values

$description : string|null = null

Optional description/help text

$default : string|null = null

Optional default value (must be in enum)

$enumNames : array<string|int, string>|null = null

Optional human-readable labels for each enum value

fromArray()

public static fromArray(array{title: string, enum: string[], description?: string, default?: string, enumNames?: string[]} $data) : self
Parameters
$data : array{title: string, enum: string[], description?: string, default?: string, enumNames?: string[]}
Return values
self

jsonSerialize()

public jsonSerialize() : array{type: string, title: string, enum: string[], description?: string, default?: string, enumNames?: string[]}
Return values
array{type: string, title: string, enum: string[], description?: string, default?: string, enumNames?: string[]}

buildBaseJson()

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

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

validateTitle()

Validate that title exists and is a string in the data array.

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