API Schemas CollectionSchemaInterface - evansims/openfga-php GitHub Wiki

Interface for collection schema definitions in the OpenFGA system. This interface extends the base SchemaInterface to provide specialized validation and structure definitions for collections of objects. Collection schemas handle arrays and lists of objects that conform to specific types, with support for wrapper keys and item requirements. Collection schemas are essential for validating complex data structures like lists of users, authorization models, relationship tuples, and other grouped data returned by the OpenFGA API. Examples of collections include Users, AuthorizationModels, Tuples, and other array-based response data that require consistent validation and type safety.

Table of Contents


Namespace

OpenFGA\Schemas


Source

View source code


Implements


Related Classes


Methods

getClassName

public function getClassName(): string

Get the fully qualified class name this schema defines. This method returns the class name that this schema describes, which is used during validation and object instantiation to ensure the correct model class is created.

View source


Returns

string — The fully qualified class name for the model this schema defines


getItemType

public function getItemType(): string

Get the type of each item in the collection.

View source


Returns

string


getProperties

public function getProperties(): array<string, SchemaProperty>

Get all properties defined in this schema. This method returns a comprehensive collection of all properties that make up this schema, including their validation rules, types, and default values. Each property defines how a specific field should be validated and processed.

View source


Returns

array&lt;string, [SchemaProperty](SchemaProperty)&gt; — An associative array of property names to their schema property definitions


getProperty

public function getProperty(string $name): SchemaProperty|null

Get a specific property definition by name. This method retrieves the schema definition for a particular property, allowing you to access its validation rules, type information, and other metadata for individual fields.

View source


Parameters

Name Type Description
$name string The name of the property to retrieve

Returns

SchemaProperty | null — The property definition if it exists, or null if the property is not defined in this schema


getWrapperKey

public function getWrapperKey(): string|null

Get the wrapper key for the collection data if any. Some collections expect data wrapped in a specific key (for example, Usersets uses 'child').

View source


Returns

string | null — The wrapper key or null if data is not wrapped


requiresItems

public function requiresItems(): bool

Whether the collection requires at least one item.

View source


Returns

bool — True if the collection must contain at least one item, false if empty collections are allowed

⚠️ **GitHub.com Fallback** ⚠️