public function addSortBy(
        Result $result,
        string $field,
        string $mode
    ): ? string {
        $urlParameters = $this->generateQueryUrlParameters($result);

        if (
            isset($urlParameters['sort_by'][$field]) &&
            $urlParameters['sort_by'][$field] == $mode
        ) {
            return null;
        }

        if (
            !isset($urlParameters['sort_by']) &&
            SortBy::SCORE === [$field => $mode]
        ) {
            return null;
        }

        unset($urlParameters['sort_by']);

        if (SortBy::SCORE !== [$field => $mode]) {
            $urlParameters['sort_by'][$field] = $mode;
        }

        return $this->createUrlByUrlParameters(
            $result,
            $urlParameters
        )['route'];
    }
public function addSortBy(
        Result $result,
        string $field,
        string $mode
    ): ? string {
        $urlParameters = $this->generateQueryUrlParameters($result);

        if (
            isset($urlParameters['sort_by'][$field]) &&
            $urlParameters['sort_by'][$field] == $mode
        ) {
            return null;
        }

        if (
            !isset($urlParameters['sort_by']) &&
            SortBy::SCORE === [$field => $mode]
        ) {
            return null;
        }

        unset($urlParameters['sort_by']);

        if (SortBy::SCORE !== [$field => $mode]) {
            $urlParameters['sort_by'][$field] = $mode;
        }

        return $this->createUrlByUrlParameters(
            $result,
            $urlParameters
        )['route'];
    }
public function addSortBy ( Result $ result , string $ field , string $ mode ) : ? string { $ urlParameters = $ this -> generateQueryUrlParameters ( $ result ) ; if ( isset ( $ urlParameters [ 'sort_by' ] [ $ field ] ) && $ urlParameters [ 'sort_by' ] [ $ field ] == $ mode ) { return null ; } if ( ! isset ( $ urlParameters [ 'sort_by' ] ) && SortBy :: SCORE === [ $ field => $ mode ] ) { return null ; } unset ( $ urlParameters [ 'sort_by' ] ) ; if ( SortBy :: SCORE !== [ $ field => $ mode ] ) { $ urlParameters [ 'sort_by' ] [ $ field ] = $ mode ; } return $ this -> createUrlByUrlParameters ( $ result , $ urlParameters ) [ 'route' ] ; }
Add sort by. Return null if doesn't change.

@param Result $result
@param string $field
@param string $mode

@return string
Add sort by . Return null if doesn t change .