Garden\Schema::filterData PHP Method

filterData() protected method

Filter fields not in the schema. The action taken is determined by the configured validation behavior.
protected filterData ( array &$data, array $schema, Validation &$validation, string $path = '' ) : Schema
$data array
$schema array The schema array. Its configured parameters are used to filter $data.
$validation Validation
$path string The path to current parameters for nested objects.
return Schema Returns the current instance for fluent calls.
    protected function filterData(array &$data, array $schema, Validation &$validation, $path = '')
    {
        foreach ($data as $key => $val) {
            if (array_key_exists($key, $schema)) {
                continue;
            }
            $errorMessage = sprintft('Unexpected parameter: %1$s.', $path . $key);
            switch ($this->validationBehavior) {
                case self::VALIDATE_EXCEPTION:
                    $validation->addError('unexpected_parameter', $key, ['parameter' => $key, 'message' => $errorMessage, 'status' => 500]);
                    continue;
                case self::VALIDATE_NOTICE:
                    trigger_error($errorMessage, E_USER_NOTICE);
                case self::VALIDATE_REMOVE:
                default:
                    unset($data[$key]);
            }
        }
        return $this;
    }