WordPress\AiClient\Providers\Models\DTO

SupportedOption::isSupportedValuepublicWP 0.1.0

Checks if a value is supported for this option.

Method of the class: SupportedOption{}

No Hooks.

Returns

true|false. True if the value is supported, false otherwise.

Usage

$SupportedOption = new SupportedOption();
$SupportedOption->isSupportedValue( $value ): bool;
$value(mixed) (required)
The value to check.

Changelog

Since 0.1.0 Introduced.

SupportedOption::isSupportedValue() code WP 7.0

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;
}