private function formatParameters(array $parameters, string $type): array
    {
        $this->checkQueryRepositoryCompatibility($type);
        $this->checkQueryResourceId($parameters, $type);

        $returnParameters = [];

        foreach ($parameters['query'] as $parameter => $value) {
            // The parameter is a filter,
            // so it must be checked if it is whitelisted
            if ('filter_by' === $parameter) {
                $returnParameters['filter'] = $this->queryAddFilterByParameter($value);

                continue;
            }

            // The parameter is a sorting field,
            // so it must be checked if it is whitelisted
            if ('sort_by' === $parameter) {
                $returnParameters['sort'] = $this->queryAddSortByParameter($value);

                continue;
            }

            // The parameter is a list of fields,
            // so it must be checked whether they are supported by the Repository
            if ('field_list' === $parameter) {
                $returnParameters['field_list'] = $this->queryAddFieldList($type, $value);

                continue;
            }

            // The parameter is of any other kind,
            // so it must be checked that it is supported by the Repository
            if (!\in_array($parameter, $this->queryParameters, true)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Parameter %s is not a valid query parameters for repository %s',
                    $parameter,
                    $this->name
                ));
            }
            if (!\is_string($value) && !\is_numeric($value)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Value for parameter %s is not a valid type, must be either a string or a number, %s given',
                    $parameter,
                    \gettype($value)
                ));
            }
            $returnParameters[$parameter] = $value;
        }

        return [
            'parameters' => $returnParameters,
            'resource_id' => $parameters['resource_id'],
        ];
    }
private function formatParameters(array $parameters, string $type): array
    {
        $this->checkQueryRepositoryCompatibility($type);
        $this->checkQueryResourceId($parameters, $type);

        $returnParameters = [];

        foreach ($parameters['query'] as $parameter => $value) {
            // The parameter is a filter,
            // so it must be checked if it is whitelisted
            if ('filter_by' === $parameter) {
                $returnParameters['filter'] = $this->queryAddFilterByParameter($value);

                continue;
            }

            // The parameter is a sorting field,
            // so it must be checked if it is whitelisted
            if ('sort_by' === $parameter) {
                $returnParameters['sort'] = $this->queryAddSortByParameter($value);

                continue;
            }

            // The parameter is a list of fields,
            // so it must be checked whether they are supported by the Repository
            if ('field_list' === $parameter) {
                $returnParameters['field_list'] = $this->queryAddFieldList($type, $value);

                continue;
            }

            // The parameter is of any other kind,
            // so it must be checked that it is supported by the Repository
            if (!\in_array($parameter, $this->queryParameters, true)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Parameter %s is not a valid query parameters for repository %s',
                    $parameter,
                    $this->name
                ));
            }
            if (!\is_string($value) && !\is_numeric($value)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Value for parameter %s is not a valid type, must be either a string or a number, %s given',
                    $parameter,
                    \gettype($value)
                ));
            }
            $returnParameters[$parameter] = $value;
        }

        return [
            'parameters' => $returnParameters,
            'resource_id' => $parameters['resource_id'],
        ];
    }
private function formatParameters ( array $ parameters , string $ type ) : array { $ this -> checkQueryRepositoryCompatibility ( $ type ) ; $ this -> checkQueryResourceId ( $ parameters , $ type ) ; $ returnParameters = [ ] ; foreach ( $ parameters [ 'query' ] as $ parameter => $ value ) { // The parameter is a filter, // so it must be checked if it is whitelisted if ( 'filter_by' === $ parameter ) { $ returnParameters [ 'filter' ] = $ this -> queryAddFilterByParameter ( $ value ) ; continue ; } // The parameter is a sorting field, // so it must be checked if it is whitelisted if ( 'sort_by' === $ parameter ) { $ returnParameters [ 'sort' ] = $ this -> queryAddSortByParameter ( $ value ) ; continue ; } // The parameter is a list of fields, // so it must be checked whether they are supported by the Repository if ( 'field_list' === $ parameter ) { $ returnParameters [ 'field_list' ] = $ this -> queryAddFieldList ( $ type , $ value ) ; continue ; } // The parameter is of any other kind, // so it must be checked that it is supported by the Repository if ( ! \ in_array ( $ parameter , $ this -> queryParameters , true ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Parameter %s is not a valid query parameters for repository %s' , $ parameter , $ this -> name ) ) ; } if ( ! \ is_string ( $ value ) && ! \ is_numeric ( $ value ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Value for parameter %s is not a valid type, must be either a string or a number, %s given' , $ parameter , \ gettype ( $ value ) ) ) ; } $ returnParameters [ $ parameter ] = $ value ; } return [ 'parameters' => $ returnParameters , 'resource_id' => $ parameters [ 'resource_id' ] , ] ; }
Formats and performs checks on the given parameters.

@param array  $parameters
@param string $type

@throws \InvalidArgumentException

@return array
Formats and performs checks on the given parameters .