ClassDiscovery::evaluateCondition( $condition ): bool

In this article

Evaluates conditions to boolean.

Return

bool

Source

protected static function evaluateCondition($condition)
{
    if (is_string($condition)) {
        // Should be extended for functions, extensions???
        return self::safeClassExists($condition);
    }
    if (is_callable($condition)) {
        return (bool) $condition();
    }
    if (is_bool($condition)) {
        return $condition;
    }
    if (is_array($condition)) {
        foreach ($condition as $c) {
            if (\false === static::evaluateCondition($c)) {
                // Immediately stop execution if the condition is false
                return \false;
            }
        }
        return \true;
    }
    return \false;
}

User Contributed Notes

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