SupportedOption::isSupportedValue( mixed $value ): bool

In this article

Checks if a value is supported for this option.

Parameters

$valuemixedrequired
The value to check.

Return

bool True if the value is supported, false otherwise.

Source

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

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.