wppaste
WordPress

SupportedOption

Since
0.1.0
Source
wp-includes/php-ai-client/src/Providers/Models/DTO/SupportedOption.php:25
Represents a supported configuration option for an AI model.

Description

This class defines an option that a model supports, including its name and the values that are valid for that option.

Compatibility

WordPress
since 0.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 2 of the 5 tracked releases, added in 0.1.0.

Properties · 2

$nameWordPress\AiClient\Providers\Models\Enums\OptionEnumprotected
$supportedValuesWordPress\AiClient\Providers\Models\DTO\list<mixed>|nullprotected

Methods · 9

Source code

class SupportedOption extends AbstractDataTransferObject{    public const KEY_NAME = 'name';    public const KEY_SUPPORTED_VALUES = 'supportedValues';    /**     * @var OptionEnum The option name.     */    protected OptionEnum $name;    /**     * @var list<mixed>|null The supported values for this option.     */    protected ?array $supportedValues;    /**     * Constructor.     *     * @since 0.1.0     *     * @param OptionEnum $name The option name.     * @param list<mixed>|null $supportedValues The supported values for this option, or null if any value is supported.     *     * @throws InvalidArgumentException If supportedValues is not null and not a list.     */    public function __construct(OptionEnum $name, ?array $supportedValues = null)    {        if ($supportedValues !== null && !array_is_list($supportedValues)) {            throw new InvalidArgumentException('Supported values must be a list array.');        }        $this->name = $name;        $this->supportedValues = $supportedValues;    }    /**     * Gets the option name.     *     * @since 0.1.0     *     * @return OptionEnum The option name.     */    public function getName(): OptionEnum    {        return $this->name;    }    /**     * Checks if a value is supported for this option.     *     * @since 0.1.0     *     * @param mixed $value The value to check.     * @return bool True if the value is supported, false otherwise.     */    public function isSupportedValue($value): bool    {        // If supportedValues is null, any value is supported        if ($this->supportedValues === null) {            return \true;        }        // If the value is an array, consider it a set (i.e. order doesn't matter).        if (is_array($value)) {            $normalizedValue = self::normalizeArrayForComparison($value);            foreach ($this->supportedValues as $supportedValue) {                if (!is_array($supportedValue)) {                    continue;                }                $normalizedSupported = self::normalizeArrayForComparison($supportedValue);                if ($normalizedValue === $normalizedSupported) {                    return \true;                }            }            return \false;        }        $normalizedValue = self::normalizeValue($value);        foreach ($this->supportedValues as $supportedValue) {            if (self::normalizeValue($supportedValue) === $normalizedValue) {                return \true;            }        }        return \false;    }    /**     * Normalizes an AbstractEnum instance to its string value.     *

Changelog

Introduced in 0.1.0. Unchanged from 7.0.4 through 7.1.0.

  1. 7.0.4
  2. 7.1.0

Signature, return type and hooks compared across 2 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/php-ai-client/src/Providers/Models/DTO/SupportedOption.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.