PHP Class LdapTools\Query\LdapResultSorter

Author: Chad Sikorra ([email protected])
Datei anzeigen Open project: ldaptools/ldaptools

Protected Properties

Property Type Description
$aliases LdapTools\Schema\LdapObjectSchema[]
$caseSensitive boolean
$orderBy array

Public Methods

Method Description
__construct ( array $orderBy = [], array $aliases = [] )
getIsCaseSensitive ( ) : boolean Get whether or not the results will be sorted case-sensitive.
setIsCaseSensitive ( boolean $caseSensitive ) Set whether or not the results will be sorted case-sensitive.
sort ( array | LdapObjectCollection $results ) : array | LdapObjectCollection Reorganize the array to the desired orderBy methods passed to the class.

Protected Methods

Method Description
compare ( string $value1, string $value2 ) : integer Taking into account case-sensitivity compare the 2 string values.
convertValueToString ( mixed $value ) : string Certain cases may require the value to be specifically changed to a string, as not every object has default string representation. The most common wanting to be sorted would likely be a DateTime object.
getComparisonValue ( array | LdapObject $entry, string $attribute ) : mixed Determine how to get the value for the attribute from the LDAP entry being compared, and return that value.
getUsortReturnValue ( string $attribute, string $direction, array | LdapObject $a, array | LdapObject $b ) : integer Based on the attribute and direction, compare the LDAP objects to get a return value for usort.
resultSortCallback ( mixed $a, mixed $b ) : integer Goes through each orderBy value to run a comparison to determine the value to pass back to usort.

Method Details

__construct() public method

public __construct ( array $orderBy = [], array $aliases = [] )
$orderBy array
$aliases array The aliases used, if any (in the form of ['alias' => LdapObjectSchema])

compare() protected method

Taking into account case-sensitivity compare the 2 string values.
protected compare ( string $value1, string $value2 ) : integer
$value1 string
$value2 string
return integer

convertValueToString() protected method

Certain cases may require the value to be specifically changed to a string, as not every object has default string representation. The most common wanting to be sorted would likely be a DateTime object.
protected convertValueToString ( mixed $value ) : string
$value mixed
return string

getComparisonValue() protected method

Determine how to get the value for the attribute from the LDAP entry being compared, and return that value.
protected getComparisonValue ( array | LdapObject $entry, string $attribute ) : mixed
$entry array | LdapTools\Object\LdapObject
$attribute string
return mixed

getIsCaseSensitive() public method

Get whether or not the results will be sorted case-sensitive.
public getIsCaseSensitive ( ) : boolean
return boolean

getUsortReturnValue() protected method

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
return integer

resultSortCallback() protected method

Goes through each orderBy value to run a comparison to determine the value to pass back to usort.
protected resultSortCallback ( mixed $a, mixed $b ) : integer
$a mixed
$b mixed
return integer

setIsCaseSensitive() public method

Set whether or not the results will be sorted case-sensitive.
public setIsCaseSensitive ( boolean $caseSensitive )
$caseSensitive boolean

sort() public method

Reorganize the array to the desired orderBy methods passed to the class.
public sort ( array | LdapObjectCollection $results ) : array | LdapObjectCollection
$results array | LdapTools\Object\LdapObjectCollection The unsorted result set.
return array | LdapTools\Object\LdapObjectCollection The sorted result set.

Property Details

$aliases protected_oe property

protected LdapObjectSchema[],LdapTools\Schema $aliases
return LdapTools\Schema\LdapObjectSchema[]

$caseSensitive protected_oe property

protected bool $caseSensitive
return boolean

$orderBy protected_oe property

protected array $orderBy
return array