Skip to content

GeneralParameterFilter, array_walk -> trim #60

@gavro

Description

@gavro

Is this extra array_walk doing anything to the values? https://github.com/marlon-be/marlon-ogone/blob/master/lib/Ogone/ParameterFilter/GeneralParameterFilter.php#L19

As far as I can tell it's not changing any of the values as the trimmed values are not saved in the original values by trim().

Note: If you decide to fix this with a proper callback so that original values get changed, be careful to only trim values which are of type "string". Trimming int/float results in string and Ogone will fail when, for example, "AMOUNT" is a string.

Something like:

    public function filter(array $parameters)
    {
        $parameters = array_change_key_case($parameters, CASE_UPPER);

        array_walk($parameters, function (&$value) {
            $value = is_string($value) ? trim($value) : $value;
        });

        $parameters = array_filter($parameters, function ($value) {
            return (bool) strlen($value);
        });

        return $parameters;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions