wol-soft/php-json-schema-model-generator

View on GitHub
src/Templates/Validator/Filter.phptpl

Summary

Maintainability
Test Coverage
{% if skipTransformedValuesCheck %}{{ skipTransformedValuesCheck }} && {% endif %}
(
    {% if typeCheck %}{{ typeCheck }} || {% endif %}
    (function (&$value) use (&$transformationFailed): bool {
        // make sure exceptions from the filter are caught and added to the error handling
        try {
            $value = \{{ filterClass }}::{{ filterMethod }}($value, {{ filterOptions }});
        } catch (\Throwable $filterException) {
            {% if isTransformingFilter %}
                $transformationFailed = true;
            {% endif %}

            {{ viewHelper.validationError(filterValueValidator) }}
        }

        return false;
    })($value)
)