protected function parseSort(string $sort, array &$sorts)
    {
        if (strlen(trim($sort)) === 0) {
            return;
        }
        if (substr($sort, 0, 1) == "[") {
            // it might be the ridiculous JSON ExtJS sort format
            $json = json_decode($sort);
            if (is_array($json)) {
                foreach ($json as $s) {
                    if (is_object($s)) {
                        $sorts[$s->property] = strcasecmp(self::DESC, $s->direction) !== 0;
                    }
                }
                return;
            }
        }
        if (substr($sort, -4) == ",asc") {
        // foo,asc
            $sorts[substr($sort, 0, strlen($sort) - 4)] = true;
        } elseif (substr($sort, -5) == ",desc") {
        // foo,desc
            $sorts[substr($sort, 0, strlen($sort) - 5)] = false;
        } elseif (substr($sort, -10) == ":ascending") {
        // foo:ascending
            $sorts[substr($sort, 0, strlen($sort) - 10)] = true;
        } elseif (substr($sort, -11) == ":descending") {
        // foo:descending
            $sorts[substr($sort, 0, strlen($sort) - 11)] = false;
        } else {
            foreach (explode(',', $sort) as $s) {
                if (substr($s, 0, 1) === '-') {
                // -foo
                    $sorts[substr($s, 1)] = false;
                } elseif (substr($s, 0, 1) === '+') {
                // +foo
                    $sorts[substr($s, 1)] = true;
                } else {
                // foo
                    $sorts[$s] = true;
                }
            }
        }
    }
protected function parseSort(string $sort, array &$sorts)
    {
        if (strlen(trim($sort)) === 0) {
            return;
        }
        if (substr($sort, 0, 1) == "[") {
            // it might be the ridiculous JSON ExtJS sort format
            $json = json_decode($sort);
            if (is_array($json)) {
                foreach ($json as $s) {
                    if (is_object($s)) {
                        $sorts[$s->property] = strcasecmp(self::DESC, $s->direction) !== 0;
                    }
                }
                return;
            }
        }
        if (substr($sort, -4) == ",asc") {
        // foo,asc
            $sorts[substr($sort, 0, strlen($sort) - 4)] = true;
        } elseif (substr($sort, -5) == ",desc") {
        // foo,desc
            $sorts[substr($sort, 0, strlen($sort) - 5)] = false;
        } elseif (substr($sort, -10) == ":ascending") {
        // foo:ascending
            $sorts[substr($sort, 0, strlen($sort) - 10)] = true;
        } elseif (substr($sort, -11) == ":descending") {
        // foo:descending
            $sorts[substr($sort, 0, strlen($sort) - 11)] = false;
        } else {
            foreach (explode(',', $sort) as $s) {
                if (substr($s, 0, 1) === '-') {
                // -foo
                    $sorts[substr($s, 1)] = false;
                } elseif (substr($s, 0, 1) === '+') {
                // +foo
                    $sorts[substr($s, 1)] = true;
                } else {
                // foo
                    $sorts[$s] = true;
                }
            }
        }
    }
protected function parseSort ( string $ sort , array & $ sorts ) { if ( strlen ( trim ( $ sort ) ) === 0 ) { return ; } if ( substr ( $ sort , 0 , 1 ) == "[" ) { // it might be the ridiculous JSON ExtJS sort format $ json = json_decode ( $ sort ) ; if ( is_array ( $ json ) ) { foreach ( $ json as $ s ) { if ( is_object ( $ s ) ) { $ sorts [ $ s -> property ] = strcasecmp ( self :: DESC , $ s -> direction ) !== 0 ; } } return ; } } if ( substr ( $ sort , - 4 ) == ",asc" ) { // foo,asc $ sorts [ substr ( $ sort , 0 , strlen ( $ sort ) - 4 ) ] = true ; } elseif ( substr ( $ sort , - 5 ) == ",desc" ) { // foo,desc $ sorts [ substr ( $ sort , 0 , strlen ( $ sort ) - 5 ) ] = false ; } elseif ( substr ( $ sort , - 10 ) == ":ascending" ) { // foo:ascending $ sorts [ substr ( $ sort , 0 , strlen ( $ sort ) - 10 ) ] = true ; } elseif ( substr ( $ sort , - 11 ) == ":descending" ) { // foo:descending $ sorts [ substr ( $ sort , 0 , strlen ( $ sort ) - 11 ) ] = false ; } else { foreach ( explode ( ',' , $ sort ) as $ s ) { if ( substr ( $ s , 0 , 1 ) === '-' ) { // -foo $ sorts [ substr ( $ s , 1 ) ] = false ; } elseif ( substr ( $ s , 0 , 1 ) === '+' ) { // +foo $ sorts [ substr ( $ s , 1 ) ] = true ; } else { // foo $ sorts [ $ s ] = true ; } } } }
Attempts to parse a single sort value.

@param string $sort The sort value
@param array<string,bool> $sorts String keys to boolean values
Attempts to parse a single sort value .