LdapTools\Query\LdapResultSorter::getUsortReturnValue PHP Метод

getUsortReturnValue() защищенный Метод

Based on the attribute and direction, compare the LDAP objects to get a return value for usort.
protected getUsortReturnValue ( string $attribute, string $direction, array | LdapObject $a, array | LdapObject $b ) : integer
$attribute string
$direction string
$a array | LdapTools\Object\LdapObject
$b array | LdapTools\Object\LdapObject
Результат integer
    protected function getUsortReturnValue($attribute, $direction, $a, $b)
    {
        $compare = [$this->getComparisonValue($a, $attribute), $this->getComparisonValue($b, $attribute)];
        // Depending on the direction of the sort, the order of the comparison may need to be reversed.
        $compare = $direction == LdapQuery::ORDER['DESC'] ? array_reverse($compare) : $compare;
        // This makes sure that objects with non-existent/empty valued attributes go to the end.
        // I think this would probably be the desired behavior?
        if (empty($compare[0]) && !empty($compare[1])) {
            return $direction == LdapQuery::ORDER['ASC'] ? 1 : -1;
        } elseif (empty($compare[1]) && !empty($compare[0])) {
            return $direction == LdapQuery::ORDER['ASC'] ? -1 : 1;
        } else {
            return $this->compare(...$compare);
        }
    }