Themosis\Route\Route::parseConditionalParameters PHP Method

parseConditionalParameters() protected method

Parses the conditional parameter out of the action parameter. This is the parameter given to WordPress conditional functions later.
protected parseConditionalParameters ( array $action ) : array
$action array The action parameter where the conditional parameters are in
return array An array with the conditional parameters or null
    protected function parseConditionalParameters($action)
    {
        // Retrieve parameters. Accept only string or array.
        // This help filter the $action parameters as it might also be a Closure.
        $parameters = Arr::first($action, function ($value, $key) {
            return is_string($value) || is_array($value);
        });
        if ($this->condition() && !is_null($parameters)) {
            if (is_string($parameters) && strrpos($parameters, '@') !== false) {
                /**
                 * In case of a controller value statement, return empty array.
                 */
                return [];
            }
            return is_array($parameters) ? $parameters : [$parameters];
        }
        return [];
    }