abstract class Type extends JsonSchema

Properties

protected bool|null $required

Whether the type is required.

protected string|null $title

The type's title.

protected string|null $description

The type's description.

protected mixed $default

The default value for the type.

protected bool $hasDefault

Whether a default value was provided.

protected null|array<int, mixed> $enum

The set of allowed values for the type.

protected bool|null $nullable

Indicates if the type is nullable.

Methods

static Type
fromArray(array $schema)

Build a type from a raw array of the Hypervel-supported JSON Schema subset.

static Type
__callStatic(string $name, array $arguments)

Dynamically pass static methods to the schema instance.

static ObjectType
object(Closure|array<string $, Type> $properties = '[]')

No description

static AnyOfType
anyOf(Closure|array<int $, Type> $schemas)

No description

static IntegerType
integer()

No description

static NumberType
number()

No description

static StringType
string()

No description

static BooleanType
boolean()

No description

static ArrayType
array()

No description

static UnionType
union(array<int $, string> $types)

No description

required(bool $required = true)

Indicate that the type is required.

nullable(bool $nullable = true)

Indicate that the type may be null.

title(string $value)

Set the type's title.

description(string $value)

Set the type's description.

setDefault(mixed $value)

Set the type's default value.

enum(array|string $values)

Restrict the value to one of the provided enumerated values.

array
toArray()

Convert the type to an array.

string
toString()

Convert the type to its string representation.

string
__toString()

Convert the type to its string representation.

Details

in JsonSchema at line 38
static Type fromArray(array $schema)

Build a type from a raw array of the Hypervel-supported JSON Schema subset.

Parameters

array $schema

Return Value

Type

Exceptions

InvalidArgumentException

in JsonSchema at line 46
static Type __callStatic(string $name, array $arguments)

Dynamically pass static methods to the schema instance.

Parameters

string $name
array $arguments

Return Value

Type

in JsonSchema at line 29
static ObjectType object(Closure|array<string $, Type> $properties = '[]')

No description

Parameters

Closure|array<string $
Type> $properties

Return Value

ObjectType

in JsonSchema at line 29
static AnyOfType anyOf(Closure|array<int $, Type> $schemas)

No description

Parameters

Closure|array<int $
Type> $schemas

Return Value

AnyOfType

in JsonSchema at line 29
static IntegerType integer()

No description

Return Value

IntegerType

in JsonSchema at line 29
static NumberType number()

No description

Return Value

NumberType

in JsonSchema at line 29
static StringType string()

No description

Return Value

StringType

in JsonSchema at line 29
static BooleanType boolean()

No description

Return Value

BooleanType

in JsonSchema at line 29
static ArrayType array()

No description

Return Value

ArrayType

in JsonSchema at line 29
static UnionType union(array<int $, string> $types)

No description

Parameters

array<int $
string> $types

Return Value

UnionType

at line 56
Type required(bool $required = true)

Indicate that the type is required.

Parameters

bool $required

Return Value

Type

at line 66
Type nullable(bool $nullable = true)

Indicate that the type may be null.

Parameters

bool $nullable

Return Value

Type

at line 76
Type title(string $value)

Set the type's title.

Parameters

string $value

Return Value

Type

at line 86
Type description(string $value)

Set the type's description.

Parameters

string $value

Return Value

Type

at line 96
protected Type setDefault(mixed $value)

Set the type's default value.

Parameters

mixed $value

Return Value

Type

at line 111
Type enum(array|string $values)

Restrict the value to one of the provided enumerated values.

Parameters

array|string $values

Return Value

Type

Exceptions

InvalidArgumentException

at line 135
array toArray()

Convert the type to an array.

Return Value

array

Exceptions

InvalidArgumentException
RuntimeException

at line 147
string toString()

Convert the type to its string representation.

Return Value

string

Exceptions

InvalidArgumentException
JsonException
RuntimeException

at line 159
string __toString()

Convert the type to its string representation.

Return Value

string

Exceptions

InvalidArgumentException
JsonException
RuntimeException